RequireJS versus HeadJS

09 January 2011   4 comments   Javascript

Mind That Age!

This blog post is 7 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

ToDo apps I gave up on in 2010 03 January 2011
django-static version 1.5 automatically taking care of imported CSS 11 January 2011
Related by Keyword:
Comparing KeyCDN and DigitalOcean's new Spaces CDN 28 September 2018
django-html-validator now supports Django 2.x 13 August 2018
To CDN assets or just HTTP/2 17 May 2018
How's My WiFi? 08 December 2017
Panasonic Lumix from 2008 or a iPhone 5S from 2014 26 September 2015
Related by Text:
jQuery and Highslide JS 08 January 2008
I'm back! has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
Ever wondered how much $87 Billion is? 04 November 2003
Guake, not Yakuake or Yeahconsole 23 January 2010