While it's not possible to define a <script type="importmap">
within a module, it is possible to define it in a synchronous <script>
tag, as long as it's before any module starts executing.
Example (works in Chrome / Edge / WebKit / Safari / Firefox)
<!DOCTYPE html>
<html lang="en">
<head>
Warning this is purely a thought experiment and will probably go nowhere. The language semantics will likely be incongruent and non-rigourous. Proceed at your own risk.
Javascript always wanted to be a functional language. But for historical, political and perhaps even sensible reasons, JS's original mission was never truly fulfilled.
But what if, we take JS and start removing things. We can remove mutation, remove variables, remove classes, remove variadic signatures, remove default arguments and on and on.
What if we go back to ES1 and re-evaluate a future unperturbed by corporate circumstance.
var BlogComments = {} | |
BlogComments.controller = function (options) { | |
App.state.fetch('blogComments', `/api/blog-post/${ options.blog_id }/comments`) | |
} | |
BlogComments.view = function (ctrl, options) { | |
var comments = App.state.blogComments | |
return m('.blog-comments-component', [ |
Widget = { | |
controller: function () { | |
this.css = Widget.stylesheet().classes | |
}, | |
view: function (ctrl) { | |
return m('.widget', [ | |
m('h3', { class: ctrl.css.head }), | |
m('div', { class: ctrl.css.body }) | |
]) | |
}, |
var mod = ( function initModulator(){ | |
if( !Map ){ | |
// A naive shim for maps functionality | |
var Map = shim; | |
var WeakMap = shim; | |
} | |
// Registry of instantiation contexts | |
var contexts = new WeakMap(); | |
// All automated counts |
function multi(){ | |
var handlers = Array.prototype.filter.call( arguments, function( x ){ | |
return x instanceof Function | |
} ) | |
return function handle(){ | |
for( var i = 0; i < handlers.length; i++ ) | |
handlers[ i ].apply( this, arguments ) | |
} | |
} |
var animating = false; | |
// Define an animator consisting of optional incoming and outgoing animations. | |
// alwaysAnimate is false unless specified as true: false means an incoming animation will only trigger if an outgoing animation is also in progress. | |
// forcing dontClone to true means the outward animation will use the original element rather than a clone. This could improve performance by recycling elements, but can lead to trouble: clones have the advantage of being stripped of all event listeners. | |
function animator( incoming, outgoing, alwaysAnimate, dontClone ){ | |
// The resulting animator can be applied to any number of components | |
return function animate( x, y, z ){ | |
var config; | |
var parent; |
'use strict'; | |
function grid( axis ){ | |
var items = []; | |
var pending; | |
var container; | |
function queue(){ | |
if( pending ) ( window.cancelAnimationFrame || window.clearTimeout )( pending ); |
Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.
They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.
A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="beaker" viewBox="214.7 0 182.6 792">