0

I have a project with multiple javascript files, all formatted as AMD modules. I'm using r.js as part of my build process (using this grunt plugin to handle everything).

After I build my project, I end up with a concatenated, minified file that has jQuery, followed by all my modules ordered correctly. That said, these modules still make calls to require and define, so I need to include the entire require.js library when I send over my minified JS file to the client.

Is there any way I can build my JS such that I don't need to send require.js to the client? Like, when I build all my JS, can I just strip out the calls to define or require?

Any help would be greatly appreciated. This article from 2013 says there's no solution yet, but I'm hoping theres a fix now.

EDIT: One good suggestion I've heard is to use Almond.js, which I can do if that's the best solution to date. I was just hoping I didn't have to ship over any 3rd party library in the first place.

3
  • 1
    Doesn't using almond with r.js do that? Commented Aug 19, 2015 at 3:03
  • ^ will be your best option next to re-writing as CommonJS and using browserify (I kid). Commented Aug 19, 2015 at 3:04
  • PS - last I checked the require.js minified file was 16KB - where is the overhead you're referring to Commented Aug 19, 2015 at 3:05

1 Answer 1

1

Use almond as a replacement for require.js in your built module. Have it loaded first to give you what you need.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.