2

I'm building a site which has so many widgets. I'm using requirejs to load each widgets logic as a module.

Eg: In my homepage 20 widgets are there & I'm using require config to load all widgets js file. I can't optimize all files to a single js file using r.js during build process, because the widgets can be altered from backend. It leads to 20 extra http request.

require({
    baseUrl: 'http://example.com/',
    paths:{
        widget1:'app/wid1',
        widget2:'app/wid2',
        ....
        widget20:'app/wid20'
    },
    waitSeconds: 30
});

Question: Is it possible to dynamically merge all modules into a single file using any server side technique, to save http request?.

4

1 回答 1

1

Answering my own question:

Module server is the solution - https://github.com/google/module-server

http://www.youtube.com/watch?feature=player_embedded&v=mGENRKrdoGY

于 2013-03-30T04:15:47.640 回答