RequireJS versus HeadJS

09 January 2011   4 comments   Javascript

Powered by Fusion×

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 keywords:
Is Nginx obsolete now that we have Amazon CloudFront? 28 July 2012
Difference between $.data('foo') and $.attr('data-foo') in jQuery 10 June 2012
How I stopped worrying about IO blocking Tornado 18 September 2012
Hosting Django static images with Amazon Cloudfront (CDN) using django-static 09 July 2010
django-html-validator 20 October 2014
Secs sell! How frickin' fast this site is! (client side) 30 March 2012
My first YSlow Grade A (100)! 17 December 2008
EmailInput HTML5 friendly for Django 02 August 2011
EditDistanceMatcher - NodeJS script for doing edit distance 1 matching 05 February 2011
A script tag's type in HTML5 10 May 2011
ToDo apps I gave up on in 2010 03 January 2011
DoneCal homepage now able to do 10,000 requests/second 13 February 2011