News for hackers. Stuff that matters.
Re:LoadJS – A tiny async loader for modern browsers (710 bytes) by pygy_ on Wednesday December 14, 2016 @07:33AM (#13175487)
https://github.com/walmartlabs/little-loader is smaller (519 bytes min+gzipped), supports IE8, and fires either on script load or on error synchronoulsy (so that globals won't be overwritten by code that runs between script loading and the callback firing). The thing is tested on SauceLabs down to IE8.

The drawback is a lower level API, and it is JS only. AFAIK loading CSS consistently cross browser is also a mine field if you want consistent error handling.

    window._lload("http://example.com/foo.js", function (err) {
        // `err` is script load error.
        // otherwise, foo.js is loaded!
      }/*, [optional context (`this`) variable here] */);
Re:LoadJS – A tiny async loader for modern browsers (710 bytes) by andres on Wednesday December 14, 2016 @08:27AM (#13175750)
The original bare-bones version of LoadJS was down to 455 bytes and grew to 710 as we added some useful features (e.g. CSS loading, async false support, load retries).

Initially I was hesitant to add CSS support because handling load errors across browsers is very tricky but I think we came up with a good solution [1] that is tested down to IE9 [2].

[1] https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L...

[2] https://github.com/muicss/loadjs/blob/master/test/tests.js#L...

Re:LoadJS – A tiny async loader for modern browsers (710 bytes) by pygy_ on Wednesday December 14, 2016 @10:11AM (#13176464)
Good job on detecting CSS loading failures.

The little-loader also has a section to detect JS loading and errors in IE8/9 (with a dedicated sub-section for the former), I didn't see anything like this in LoadJS... Did you find a terser workaround?

https://github.com/walmartlabs/little-loader/blob/42d233f360...

I'm somewhat familiar with little-loader because I've worked at making it smaller, but I'm not competent to judge whether its approach is necessarily the best...

Re:LoadJS – A tiny async loader for modern browsers (710 bytes) by andres on Wednesday December 14, 2016 @11:13AM (#13177069)
We use the `onerror` handler to detect load errors on IE9: https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L...