optimization - When using the requireJS optimizer, what's the advantages of buildlayered javascript? -


i'm trying first attempts requirejs optimizer r.js (here) prepare application production.

i can work , can uglify of js single main.js file, 1 file, many questions...

basic questions:

  1. what javascript buildlayer requirejs talking about? single file?

right optimized 1 module main.js, bundles dependencies single file (jquery, jquery-mobile, plus else required app started).

advanced questions:
on 1 page i'm using graph done jqplot, uses xy additional javascript files don't need anywhere else in app.

  1. what need prevent these files showing in main.built.js file?
  2. do need define new module graph on page i'm using graph , optimize module concat xy files graph.built.js

very advanced:
page made of gadgets = autonomous blocks of html/js/css i'm reusing throughout application , can customized using json.

  1. if loading gadgets via requirejs !text plugin, html files "optimized to" large single html file?
  2. if want load gadgets need on each page, have create module per page dependencies each gadget , optimize module index_page, module page_with_graph, etc. make sure what's needed gets loaded?
  3. if doing so, re-request gadgets on every page vs caching?

thanks sheding insights!

great guestions!

basic questions:

what javascript buildlayer requirejs talking about? single file?

firstlly, lets rephrase buildlayer "bundle", has more objective meaning. concatinated modules set. single - if put or modules in 1 build or few if build specified build pages.

advanced questions:

what need prevent these files showing in main.built.js file?

first of all, here usefull link have in bookmarks - https://github.com/jrburke/r.js/blob/master/build/example.build.js

in few words can configure modules section in r.js configs managing include , exlcude rules reach goal

do need define new module graph on page i'm using graph , optimize module concat xy files graph.built.js

you can use shim , request in on demand on other modules

very advanced:

if loading gadgets via requirejs !text plugin, html files "optimized to" large single html file?

nope, in build.js. result had loading templates via !text

if want load gadgets need on each page, have create module per page dependencies each gadget , optimize module index_page, module page_with_graph, etc. make sure what's needed gets loaded?

you can build own buldle each page, not best idea. when had similar question i've decided build 1 bundle because of 2 reasons - loads ones, more easy control cache on cdn , decrease possible errors , mistakes. if need separate bundles follow link a've posted modules section.

if doing so, re-request gadgets on every page vs caching

so if load page , have dep1 in 10 modules dependencies file loaded once (if dont have in buld.js) , injected in modules. when reload page file may browser cache or loaded again according browser config.

hope help.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -