Closed benmccann closed 10 years ago
Hi Ben
rjs concats main.js (configurable) and the scripts it depends on into main.js. It does not therefore change the URL.
rjs is not normally used during dev, just prod.
HTH
We should update the docs to clarify this.
Thanks @huntc. That's what I believed from a few presentations I saw online, but wasn't entirely sure.
It sounds like dev and prod mode have different usage, so would it be something like this then?
@if(play.Play.application().isProd()) {
<script type="text/javascript" src="@routes.Assets.at("javascripts/main.js")"></script>
} else {
<script data-main="@routes.Assets.at("javascripts/main.js")" src="@routes.Assets.at("lib/requirejs/require.js")"></script>
}
Nope, it is the same script statement for both:
<script data-main="@routes.Assets.at('javascripts/main.js')" src="@routes.Assets.at('lib/requirejs/require.js')"></script>
Hmm, really? That's surprising to me. I thought that I production mode that this plugin combined all the scripts. So in that case why do you still need to load require.js instead of just main.js (i.e. the optimized script)?
require.js
is bootstrap script for RequireJs - you always need the data-main
attribute.
Ah, it looks like you're right. At least by default that's the behavior. It seems you may be able to make it behave in the manner I expected by setting some extra options, which I'll probably look into as it seems like it'd result in better latency for the end user.
Thanks @huntc for the clarifications! I'm going to close this. I submitted a pull request for the extra docs
Thanks for the plugin. I wanted to check it out to see the way you guys develop JS. Some questions I have trying to get it to work: