Re:Show HN: LoadJS – A tiny async loader for modern browsers
by teknologist on Wednesday May 18, 2016 @09:54PM
(#11727399)
For wider browser support I've always relied on LABjs. It's been around for ages and has to be among the most stable JS libraries out there despite having to deal with all those browser quirks.
[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...
https://github.com/muicss/loadjs/blob/master/src/loadjs.js
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.
http://labjs.com/
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...