RequireJS versus HeadJS

09 January 2011   4 comments   JavaScript

Mind that age!

This blog post is 10 years old! Most likely, its content is outdated. Especially if it's technical.

I've spent a lot of time trying to figure out which Javascript script loading framework to use. RequireJS or HeadJS. I still don't have an answer. Neither website refers to each other.

In general



Other alternatives

The ones I can think of are: ControlJS (feels too "hacky" for my taste), CommonJS (not sufficiently "in-browser specific" for my taste) and EnhanceJS (like HeadJS and LabJS but with less power/features)

The one I haven't studied as much is LabJS . It seems more similar to HeadJS in style. Perhaps it deserves more attention but the reason HeadJS got my attention is because it's got a better looking website.

In conclusion

You mileage will vary. The deeper I look into this I feel personal taste comes into play. It's hard enough for a single framework other to write realistic benchmarks; even harder for "evalutators" like myself to benchmark them all. It gets incrementally harder when you take into account the effects of http latency, sporadic network bottlenecks, browser garbage collection and user experience.

Personally I think HeadJS is a smoother transition for general web sites. RequireJS might be more appropriate when write web apps with virtually no HTML and a single URL.

With the risk of starting a war... If you're a Rails/Django/Plone head, consider HeadJS. If you're a mobile web app/NodeJS head consider RequireJS.


Sorry, I now realise that Tero Piirainen actually has built a fair amount of powerful Javascript libraries.



It's a pretty common practice to load javascript at the end of the page, to avoid flicker and speed rendering up.

I never heard that js must get loaded in the head, its even valid anywhere.

Peter Bengtsson

What is a common practice is not necessarily correct sometimes.

I suspect that XHTML Strict is the only one that bitches about <script> tags into the body. But most likely it's still working all the time.


For some reason this is being downvoted on Hacker News, but this is the only way these scripts could have any use to me (and some upvoters): do they enable asynchronous load of Adsense/Facebook web-freezer scripts?


Why not vanilla style? Fastest, not code affecting, full dependencies loading.

I use simple files merging tool (merge for releases and listings for debug).

It is similiar to sp[rockets but lighter, pure java, and supports all file types (like CSS).

Instead of wrapping your code with "require/amd" polluting software, just define dependencies in java style.

The key is a nice build for you project.

Your email will never ever be published.

Related posts