It’s funny I have the impression that script loaders keep coming back in the news, if we go back one year and a half ago we mostly only had labJS and requireJS, these guys want to load all your scripts asynch, but now we got new kids, notably yepnope, that allows you to load scripts based on feature detection and others.. headJS, controlJS, enhanceJS, jsDefer ouch…
Script loaders are responding to a weird problem, you would think that browsers do a good job at loading script since its been doing just that for more than 10 years, but in fact not really, it could be a lot better and this is where those technologies come in.
What they do is super charge the loading speed of your scripts by using various tricks, and when I say tricks, sometimes it really means hacks, specially in older browsers like ie6. In my article about script loaders 1 year ago I gave them praised, and I definitely meant it, but currently I unfortunately just stopped using loaders.
What went wrong?
When I first tested labJS I was flabbergasted, it was loading my scripts 3 times faster on a average website. I was looking at optimizing the front-end speed of our framework at my last job (w.illi.am/ a web consulting/agency), and this was a strong contender at being implemented. And we did just that, we implemented labJS at the core of our CMS. It definitely took some fine tuning and we had some weird bugs at first with execution order and dom ready statements, but within a week or 2 everything was back to normal.
Then a new project came with an IE phase testing, to our horror IE8 was giving us wrong error lines, it did not understand what labJS was doing and could not find any script file loaded by labjs. Still we continued to use it. Then Firefox4 came along, our older labjs version was not compatible with it, this was a big problem for us, since w.illi.am/ does something like 50 websites a year, not centralized. We just could not afford to update labJS for each project. This was the end of script loading for us, we had to revert back to our old way, we could not take the chance that older version would not be compatible with future browsers.
** I also heard that some of them had problems with newer webkit releases, prompting another library update.
Is it really worth it to use a script loader?
Personally my response would be no, you introduce in your stack a very big point of failure, if this script fails, your entire app fails, furthermore you *generally* need to follow convention dictated by the library. RequireJS works best if you follow their module convention, and labJS has an api to make it easier to keep the execution order, but it really changes the way you would normally work.
That being said, I still think script loaders are a brilliant technology, and I have a lot of respect for their authors. I mean, if your looking for optimizing your page loading time to the maximum, script loaders are a no brainer, its probably your single best optimization beside doing the normal stuff, but it’s not a task to be taken lightly and you must be aware that there will be maintenance and setup cost.