![]() ![]() You can use the one JavaScript file optimization approach to make your development experience faster. Shallow exclusions for fast development § 6 If you want to wrap your built file so it can be used in pages that do not have an AMD loader like RequireJS, see the Optimization FAQ. Once that optimization is done, you can change the script tag to reference "main-built.js" instead of "require.js", and your optimized project will only need to make one script request. Since "require" is a reserved dependency name, you create a "requireLib" dependency and map it to the require.js file. paths.requireLib=././require name=main include=requireLib out=main-built.js If you want to include require.js with the main.js source, you can use this kind of command: node. Then, you can change the main-built.js file name to just main.js so the HTML page will load the optimized version of the file. ![]() Change the out= option to any directory you like, that has a copy of your source. Normally you would save them to a copy of your project, but to make this example easier it is saved with the source. Normally you should not save optimized files with your pristine project source. This will create a file called appdirectory/scripts/main-built.js that will include the contents of main.js, one.js, two.js and three.js. /r.js -o name=main out=main-built.js baseUrl=. Use the above example setup, if you just wanted to optimize main.js, you could use this command, from inside the appdirectory/scripts directory: node. In other words, the mainConfigFile configuration has the lowest priority. The precedence for config: command line, build profile, mainConfigFile. Or: define(, function (a, b) ) found in that file will be parsed out and used as part of the configuration options passed to the optimizer: mainConfigFile: 'path/to/main.js' So, it will not find modules that are loaded via a variable name: var mods = someCondition ? : īut 'a' and 'b' will be included if specified like so: require() The optimizer will only combine modules that are specified in arrays of string literals that are passed to top-level require and define calls, or the require('name') string literal calls in a simplified CommonJS wrapping. The optimizer is part of the r.js adapter for Node and Nashorn, and it is designed to be run as part of a build or packaging step after you are done with development and are ready to deploy the code for your users. Optimizes CSS by inlining CSS files referenced by and removing comments.Combines related scripts together into build layers and minifies them via UglifyJS (the default) or Closure Compiler (an option when using Java).RequireJS has an optimization tool that does the following empty: paths for network/CDN resources § 7.Shallow exclusions for fast development § 6. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |