ECMAScript 6 (ES2015) added the ‘let’ keyword. let works a lot like the legacy ‘var’ keyword, but adds scoping capabilities.
Unfortunately, support cannot be retrofitted to older browsers with a polyfill, supported by IE11(with limitations), Edge 12+, Firefox 44+, Chrome 49+, Safari 10+. If you still need to support older browsers or devices you may want to stick with var.
Formally introduced in ES6,
Unfortunately, support cannot be retrofitted to older browsers with a polyfill, supported by IE11+, Edge 12+, Firefox 36+, Chrome 21+, Safari 5.1+. If you still need to support older browsers or devices you may want to stick with
NOTE: some initial implementations may have thrown different exceptions on reassignment, were not limited in scope, or treated
const like ‘
Name may start with letter, underscore or $ character.
Minifying files for use on the web is essential to improving performance, to reduce network overhead as well as a slight bump in execution speed.
Long ago I used the YUICompressor plugin for both JS as well as CSS files, unfortunately that project appears to have been abandoned many years ago and no longer functions well for JS files that make use of modern features.
For JS files, I’ve found that most capabilities can be replicated with the following in the pom.xml:
<!-- not supported (always uses .min) <suffix>-min</suffix> -->
NOTE: the only feature I have not yet been able to match is the suffix, as it appears to always use *.min.js (where I used to prefer *-min.js).
An additional advantage of using the plugin is that many common syntax errors will be identified at build time, before they cause user problems… but they will also break your build!