RequireJS has a nice feature to optimize a JS project into one single script (let's call it foo.js
).
If I include foo.js
, I get: Uncaught ReferenceError: define is not defined
. The error goes away if I add require.js
before foo.js
, because define
is defined by RequireJS. I don't want my library users to have to do that to use it.
Can I make RequireJS embed itself inside the foo.js
in a proper way? Would concatenating files be acceptable?
Yep, the maintainer of RequireJS has put out a project just for that, almond.
I haven't used it, but from the description:
"Some developers like to use the AMD API to code modular JavaScript, but after doing an optimized build, they do not want to include a full AMD loader like RequireJS, since they do not need all that functionality. [...] By including almond in the built file, there is no need for RequireJS. "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With