27
May

Two alternatives for RequireJS

These days I’ve been looking for alternatives to RequireJS.

The reason is that rJS is a little too complex to be worth integrating with it. Not all JS libraries are AMD compatible and this brings an extra overhead. Besides, the setup time for a new project is not fast enough.

I’ve started my search for alternatives. After looking at a few libs at this link [flash content], I’ve ended up with 2 solutions that that I preffer:

  • yepnope js – used by Modernizr
  • labJS – a performance oriented script loader

Top 3 things I like about yepnope js:

  1. Ability to preload scripts without executing them. For example Gmail for mobile uses this technique for performance reasons. AFAIK RequireJS can’t do that.
  2. Ability to load CSS along with the JS files. AFAIK RequireJS doesn’t handle that. Update: as per Patrick’s comment bellow, there is a hook to achieve that eventually. Thanks Patrick !
  3. Ability to insert a test function before loading a script. I’m quoting Modernizr: “combine feature detection with media queries and conditional resource loading. That gives you the power and flexibility to optimize for every circumstance.”

2 Comments

  • Patrick Said:

    Using the text plugin (require(‘text!./template.html’)), you can load CSS files, and template files with RequireJS.

  • Peter Said:

    The best way is not to use any “loaders” as they only pollute the scope and complicate simple things.

    Personally the most unliked option is being forced to use the extra scope (and being forced to use bad practices).

    I use simple build tool that does even better job, http://sourceforge.net/projects/minimerge/

    also for CSS.

Sorry, the comment form is closed at this time.

Comments RSS Feed