cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
You are here: Foswiki>Tasks Web>Item13021 (05 Jul 2015, GeorgeClark)Edit Attach

Item13021: "use strict" is removed when minifying the code

pencil
Priority: Normal
Current State: Closed
Released In: 2.0.0
Target Release: major
Reported By: MichaelDaum
Waiting For:
Last Change By: GeorgeClark
The javascript parser of uglifyjs (our standard minifier) treats "use strict"; as a normal string literal with no use and removes it ... unless you put it in the first column:

(function($) {
"use strict";

   code 
   code 
   code 

})(jQuery);

This affects a lot of JQxxx plugins including JQueryPlugin.

Why bother? Well "use strict"; serves a couple of purposes, i.e.

  • forbid some language features that are not secure
  • enforce a certain level of code quality, i.e. use of undefined variables
  • allows the javascript compiler to optimize the code better

So when the minifier removes "use strict"; then this is actually a very bad thing to happen as it removes these constraints and actually may cost performance as well.

-- MichaelDaum - 02 Sep 2014

 
Topic revision: r11 - 05 Jul 2015, GeorgeClark - This page was cached on 21 Mar 2018 - 20:16.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License