Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Jaap authored Dec 6, 2018
1 parent 925b109 commit 75c6162
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,38 @@ grunt.initConfig({
});
```

## Module Code Splitting

Closure Compiler can split the output of a compilation into multiple files to support dynamic loading. This process uses the `--chunk` flag (before June 2018 it was named `--module`). See [how do I split my javascript into modules](https://stackoverflow.com/questions/10395810/how-do-i-split-my-javascript-into-modules-using-googles-closure-compiler/10401030#10401030)

Modules can be stitched together without a module loading logic enabling to achieve optimal compression and optimization with the ability to load modules selectively.

Source: https://github.com/google/closure-compiler/wiki/JS-Modules#code-splitting-output-modules

```javascript
grunt.initConfig({
'closure-compiler': {
frontend: {
closurePath: '/src/to/closure-compiler',
modules: {
"module-name": {
src: ['js/source.js', 'js/other-source.js']
},
"extra-module": {
src: ['js/extra-module.js'],
dep: ['module-name']
}
},
moduleOutputPath: 'static/js/',
maxBuffer: 500,
options: {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
language_in: 'ECMASCRIPT5_STRICT'
}
}
}
});
```

## Note

Expand Down

0 comments on commit 75c6162

Please sign in to comment.