5 ms·
I wish it was just the script loading and the other stuff was in a separate library. For a script that purposes to make less loading times I find it ironic that
by dinedal 16y ago
I wish it was just the script loading and the other stuff was in a separate library. For a script that purposes to make less loading times I find it ironic that it would also throw in the kitchen sink.
- timmaah 16y agohttps://github.com/headjs/headjs/blob/master/src/head.loader.js https://github.com/headjs/headjs/blob/master/src/head.loader... Head Loader: The ultimate JavaScript loader. Can be used as a standalone tool.
- trafficlight 16y agoAbsolutely. The javascript loader sounds interesting, but I don't need any of the CSS, HTML5 or screen size detection.
- deleted 16y ago[deleted]
- philfreo 16y agoIf all you need is an easy way to asynchronous / lazy load JavaScript, you can just include something like this: http://friendlybit.com/js/lazy-loading-asyncronous-javascript/ http://friendlybit.com/js/lazy-loading-asyncronous-javascrip... Or a nice function, with "Ready" support: In <head>: <script type='text/javascript'> function ljs(s){ var a=document.createElement('script'), b=document.getElementsByTagName('script')[0]; a.type='text/javascript'; a.async=true; a.src=s; b.parentNode.insertBefore(a,b) } var Ready=[]; </script> Then anywhere in the <body> or in any included scripts you can do: Ready.push(function() { //this will get executed after all the ljs files }); Then in a script that contains your JS library, append: $.ready(function() { // or some other ondomready fn // execute all the Ready functions for (var i = 0, m = Ready.length; i < m; i++) { Ready[i](); } delete Ready; });
- deleted 16y ago[deleted]
- kilian 16y agoTry out LABjs: http://labjs.com/ http://labjs.com/
- patrickaljord 16y agoOr http://yepnopejs.com/ http://yepnopejs.com/ it comes with conditional loading, based on labjs.
- storborg 16y agoThe latency difference between an HTTP req for a 2.3K script and a 500 byte script is pretty trivial. And if you're concatenating with other js assets on your site, the incremental increase in size after minification/gzipping will probably be even less than 2.3K.
- chrisbroadfoot 16y agoAgreed. It looked good until I started reading about CSS. The other stuff should be loaded asynchronously, as per their (wise) suggestion
- alanh 16y agoYou don’t understand the philosophy and failed to realize there are already number of scripts that already do this. (Let’s ignore that you you referred to 2K as “the kitchen sink.”) However some things need loaded in he head (for using HTML5 tags in IE, for example). Thus there are obvious efficiencies to be gained by essentially hybridizing Modernizr.js and LABjs. I’m now watching head.js on GitHub, and suggest you reconsider before dismissing it out of hand…