Show HN: LoadJS – A tiny async loader for modern browsers
github.com
github.com
* Replaced for-loops with while-loops [1]
* Removed un-necessary code in the script loading function [2][3]
* Removed setTimeout wrapper [4][5]
[1] https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L...[2] https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L...
[3] https://github.com/muicss/loadjs/blob/8d380e1f6c2af431b08088...
[4] https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L...
[5] https://github.com/muicss/loadjs/blob/8d380e1f6c2af431b08088...
Also using an if/else instead of continue saves 4 bytes.
Using arrow functions shaves off another 2 bytes.
(Gzipped that's 489 bytes.)[0]
[0] - https://closure-compiler.appspot.com/code/jscde34e44897623a8...
Arrow functions would be great but then we'd have to drop support for browsers that don't support ES6.
The closure compiler doesn't respect arrow functions, so I'm assuming that'd have to be changed manually.
https://github.com/sun2rise/dysel/blob/master/dist/dysel.js#...
Just stop layering bloat.
2. Why can't you just use <script async src="/js/script.js"></script> and be done with it in the first place?
https://www.stevesouders.com/blog/2012/01/13/javascript-perf...