You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The script generated with rake release generates a script that, if used without modification, does not play well with JS minifiers/obfuscators like Uglify.
Example:
/*jshint eqnull:true*/this.Handlebars={};
When run through a minifier like Uglify, will become:
this.a={};
As a result, later references to Handlebars as a global variable (vs. as a property on window) will throw reference errors.
A solution is to wrap the entire script contents in an IIFE:
You may be correct in that Uglify shouldn't be obfuscating properties on this if it's actually window, but wrapping the entire source insulates you from even having to worry about situations like this. What's the rationale for not wrapping everything in an IIFE? I'm wondering simply because this IIFE pattern is used by many other libraries (including jQuery).
Ignoring the uglify behavior (I didn't think that it would attempt to mangle anything hanging off an object...) there are some size and scoping benefits to creating one all encompassing IIFE. I've made this change and it should land in the next release.
The script generated with
rake release
generates a script that, if used without modification, does not play well with JS minifiers/obfuscators like Uglify.Example:
When run through a minifier like Uglify, will become:
As a result, later references to
Handlebars
as a global variable (vs. as a property on window) will throw reference errors.A solution is to wrap the entire script contents in an IIFE:
The text was updated successfully, but these errors were encountered: