4 ms·
RequireJS: a JavaScript file and module loader
- ahemphill 16y agoWhat makes this different/better than Head JS, LAB, et cetera? If you're familiar with the project, pitch us.
- maigret 16y agoSame here... Why would I use all these special (quite untested compared to GWT, Dojo) JavaScript libraries, instead of using Dojo - which has already a fine module layer as well as a build system.
- YuriNiyazov 16y agoI don't know why you specifically would use it, but some developers prefer to mix-n-match their toolchain rather than use everything from one project.
- jws 16y agoThe http://requirejs.org/docs/why.html http://requirejs.org/docs/why.html page covers their design decisions. (That is the extent of my knowledge.) • Loads scripts by appending to HEAD • Asynchronous – calls functions when their dependencies are loaded. • Support for a compilation to take your developer friendly cloud of javascript files and turn them into a single, closure compiled mass for faster page loads.
- YuriNiyazov 16y agoRequireJS does more work. All of those projects concentrate on loading scripts asynchronously and in parallel. However, to the best of my knowledge, they do not provide sane, standardized (standardized meaning CommonJS compatible in this case) namespacing, modularization and dependency management into your Javascript.
- unicornporn 16y agoomfg, that website is beauty itself. seriously.
- warble 16y agoDojo has many similar features - compilation, dojo.require().. might be a consideration as well if this is attractive.
- gregory80 16y agoi feel like requuireJS hit hacker news last week, and the week before that. I'm would genuinely like more information on the authors of this library. I a little confused why their examples have the script tags in the HEAD of the document, when it is well known that script tags block all other resources from loading and should be placed at the bottom of the page. http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/ http://www.stevesouders.com/blog/2009/04/27/loading-scripts-... If the authors or developers have some magic to bypass this, besides just drawing the script tags via JS as Steve Souders suggests, I would be excited to see that presented more front and center.
- YuriNiyazov 16y agoAn example for how to use RequireJS needs to be as clear and simple as possible, and putting a SCRIPT tag into HEAD is still the clearest and simplest way - the stuff that Souders writes about is Advanced JS hackery - if you understand Souders, then you also understand how to rewrite the RequireJS example to be even more efficient than it is. One of the bigger misconceptions about RequireJS is that it's about efficiency. RequireJS does provide an efficient way to load up the scripts, but that's an important side benefit of the actual reason why it exists: To provide sane modularization and dependency management of your Javascript code.
- gregory80 16y agothanx for the overview. Sounds like this falls into the same groups as LABJS and ControlJS to some degree. I don't really agree that putting the script tag in the head is a simple example. The tornado web docs, talk about loading script tags last, and they cover a lot more than just where is the best place to put script tag. http://www.tornadoweb.org/documentation http://www.tornadoweb.org/documentation I could buy the "it's okay to write demos with script tags in the head" bit in the same why I buy it's "okay" to use document.write() examples b/c it's 'fast'. Which is to say, I don't buy either argument. If requireJS is aiming at people who don't know any advanced JS 'hackery', why on earth would that same dev know they need "sane modularization and dependency management". They still think it's "okay" to load script tags from the HEAD.