News for hackers. Stuff that matters.
Re:Show HN: LoadJS – A tiny async loader for modern browsers by brudgers on Wednesday May 18, 2016 @08:47AM (#11721473)
Curious as to how 84 bytes were shaved since the previous posting. https://news.ycombinator.com/item?id=9941182
Re:Show HN: LoadJS – A tiny async loader for modern browsers by andres on Wednesday May 18, 2016 @10:39AM (#11722279)
Re:Show HN: LoadJS – A tiny async loader for modern browsers by andres on Wednesday May 18, 2016 @10:59PM (#11727650)
I just shaved off another 3 bytes so LoadJS is now 503 bytes (minified + gzipped). HN - If you see a way to get below 500 bytes please let me know!

https://github.com/muicss/loadjs/blob/master/src/loadjs.js

Re:Show HN: LoadJS – A tiny async loader for modern browsers by barsonme on Wednesday May 18, 2016 @11:32PM (#11727764)
Using ES5 features? Because arrow functions would make it smaller.

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...

Re:Show HN: LoadJS – A tiny async loader for modern browsers by andres on Wednesday May 18, 2016 @11:41PM (#11727794)
That's a good suggestion but it looks like the minifier removes "continue" automatically: https://raw.githubusercontent.com/muicss/loadjs/master/dist/...

Arrow functions would be great but then we'd have to drop support for browsers that don't support ES6.

Re:Show HN: LoadJS – A tiny async loader for modern browsers by barsonme on Thursday May 19, 2016 @12:01AM (#11727865)
It seems running your original code through the closure compiler shaves it down to 488 max.

The closure compiler doesn't respect arrow functions, so I'm assuming that'd have to be changed manually.

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.

http://labjs.com/

Re:Show HN: LoadJS – A tiny async loader for modern browsers by sunrising on Thursday May 19, 2016 @02:50AM (#11728508)
Re:Show HN: LoadJS – A tiny async loader for modern browsers by andres on Thursday May 19, 2016 @07:48AM (#11729451)
How does dysel do sequential loading? Dynamically loaded script tags default to async=true so I think this code loads/executes scripts asynchronously:

https://github.com/sun2rise/dysel/blob/master/dist/dysel.js#...

Re:Show HN: LoadJS – A tiny async loader for modern browsers by maxpert on Saturday May 21, 2016 @08:06AM (#11744401)
Nice work would love to see it delivered via CDNjs
Re:Show HN: LoadJS – A tiny async loader for modern browsers by fbdjfhhcbd on Wednesday May 18, 2016 @10:39PM (#11727580)
For what purpose?

Just stop layering bloat.

Re:Show HN: LoadJS – A tiny async loader for modern browsers by King-Aaron on Thursday May 19, 2016 @03:28AM (#11728619)
But what if you want to load four hundred dependant scripts on each pageload? :(
Re:Show HN: LoadJS – A tiny async loader for modern browsers by romanovcode on Thursday May 19, 2016 @10:25AM (#11730427)
1. If you need four hundred dependant scripts to load a page you're doing something wrong.

2. Why can't you just use <script async src="/js/script.js"></script> and be done with it in the first place?

Re:Show HN: LoadJS – A tiny async loader for modern browsers by michaelmior on Saturday May 21, 2016 @12:23AM (#11743193)
Because async doesn't do what you think it does.

https://www.stevesouders.com/blog/2012/01/13/javascript-perf...