You are here: Foswiki>Tasks Web>Item13021 (05 Jul 2015, GeorgeClark)Edit Attach

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

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";



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 04 Jun 2020 - 11:54.

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