Eliminating need for require js from optimized app

92 views Asked by At

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..?

1

There are 1 answers

0
Andreas Köberle On

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:

almond is an AMD API shim that is very small, so it can be used in place of require.js when all of your modules are built into one file using the RequireJS optimizer.