4 ms·
Require.js is a Terrible Idea
- m90 13y agoThe link 404s for me: "It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help."
- bjtitus 13y agoProbably realized how poorly researched the article was and just deleted it.
- avolcano 13y agoThis is depressingly ill-informed. Require.js has an optimizer that does exactly what the author suggests: http://requirejs.org/docs/optimization.html http://requirejs.org/docs/optimization.html The point is to build your application using AMD, using individual assets in development, and then run the optimizer - which concats and adds a loader - for production. Alternatively, you can even go a step simpler and always use concatenated files, along with a minimal loader like Almond.js[1]. If you do this, you'll probably want to use something that adds source maps for your concatenated file (for easier debugging), but that's easy - you can use grunt-concat-sourcemap[2] or a similar plugin for whatever build system you like. [1]: https://github.com/jrburke/almond https://github.com/jrburke/almond [2]: https://github.com/kozy4324/grunt-concat-sourcemap https://github.com/kozy4324/grunt-concat-sourcemap
- gpsarakis 13y agoMinifying+concatenating is the most appealing solution for desktop browsers which employ a rather large cache on static files, considering that a web server is also fine-tuned to take advantage of caching (e.g. http://httpd.apache.org/docs/2.2/mod/mod_expires.html http://httpd.apache.org/docs/2.2/mod/mod_expires.html). I am not sure though that this is the best approach for mobile devices; having to serve a relatively large JS/CSS file with (possible) network interruptions may increase page load time.
- joebeetee 13y agoTotally misses the point of Require JS - modularisation of code, dependancy management, namespacing, etc - beside the fact that it comes with an awesome optimiser that does mashes everything into one script anyway...
- lightblade 13y agoEven without require.js' r.js optimization tool, having multiple source files like this is not necessarily a bad thing. Smaller files are more likely for browsers to cache them. If you concatenate all source files into one 5MB[1] file, it is unlikely the browser is going to cache that. This is more of a trade off than absolute best thing. [1]: http://serverfault.com/questions/338722/what-is-the-maximum-file-size-that-will-be-cached-by-a-browser http://serverfault.com/questions/338722/what-is-the-maximum-...