javascript - How can I tell Google closure compiler to not remove a var -
i have following code:
// ==closurecompiler== // @output_file_name default.js // @compilation_level advanced_optimizations // ==/closurecompiler== var l = window.location; var s = 'hash'; l[s] = 'whatever need now';
which gets compiled google closure compiler (advanced mode) this:
window.location.hash="whatever need now";
but in case need keep using l[s]= ...
in compiled code.
is there way tell compiler keep using var or ignore couple of lines?
it's small hack hash function work junos pulse.
i'm having lot of trouble believing hack necessary, but:
// ==closurecompiler== // @output_file_name default.js // @compilation_level advanced_optimizations // ==/closurecompiler== eval( "var l = window.location;\n" + "var s = 'hash';\n" + "l[s] = 'whatever need now';\n" );
*hack* *cough* :-)
or:
// ==closurecompiler== // @output_file_name default.js // @compilation_level advanced_optimizations // ==/closurecompiler== sessionstorage.x = "hash"; window.location[sessionstorage.x] = 'whatever need now';
Comments
Post a Comment