I've built my app using require.js in order to keep everything modular. Having finished it turns out that require.js itself is bigger than my optimised app code. Is there some way I can get r.js to optimise in such a way that I don't need to include require.js in the final page (e.g. replacing all my define
calls with direct definition of properties on a namespace object, with the whole thing wrapped in a closure).
I'm only using define()
- never require()
, if that makes a difference..?
You still need an AMD loader but you can switch to a much lighter one, such as almond. almond is around 1 kilobyte when minified and gzipped.
From the FAQ: