Frage

I have a requirejs project with several webpages. For each webpage there's a main/require-configuration JS file that is loaded. The structure is something like this:

Something like this:

- p1.html
- p2.html
- /scripts
    - main1.js
    - main2.js
    - /controllers
        -...
    - /views
        -...
- /css
- /images

I also have an r.js build profile file for each "flow" (build-flow1.js, build-flow2.js). I'm using the requirejs optimizer (running r.js) to optimize a single JS for each flow.

I'm reconsidering this build configuration since I couldn't explain to myself what do I really earn, at runtime, from using requirejs if eventually everything is build into a single, concatenated JS file. I understand that having my code modularized with requirejs enables this r.js compilation, but as requirejs is first and foremost a loader framework, it seems like I'm earning these capabilities... Or didn't I get it right?

There's also documentation about building a whole project. It looks like its result is like in the other method (single JS files), but it also copies everything to a side folder and does it there. What's the difference?

War es hilfreich?

Lösung

Sounds like you are questioning the benefit of even bothering with RequireJS/AMD when everything gets built into one file regardless?

Someone asked a similar question and some really great answers appeared in this gist.

On top of that there is a 'Why Web Modules?' page on the RequireJS site.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top