"use strict"; prepended blindly to scripts in the wild

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Thu Sep 9 01:09:28 PDT 2010


On Tue, Sep 7, 2010 at 9:35 PM, Brendan Eich <brendan at mozilla.com> wrote:

> On Sep 7, 2010, at 10:28 AM, Boris Zbarsky wrote:
>
> > On 9/7/10 1:21 PM, Brendan Eich wrote:
> >> See, e.g., https://bugzilla.mozilla.org/show_bug.cgi?id=593963 -- but
> this is not the first instance. Previously:
> https://bugzilla.mozilla.org/show_bug.cgi?id=579119.
> >
> > The latter wasn't blind.  It was just a site concatenating a bunch of
> third-party scripts together, and one of the third-party scripts (correctly)
> using strict....  So that one is totally Amazon's flub, imo.
>
> Thanks -- this clarifies things, and makes me worry about more of the same.
>
> "Blind concatenation" is a feature as much as a bug in the history of JS.
> Combined with script inline content moving out to src= URL-named convent, it
> is how we end up with Unicode BOMs and <!-- pseudo-comments in the middle of
> files.
>
>
Currently, a site may normally concatenate 3rd-party libs with "use strict"
at the global level. The technique is the same as with forgotten semicolon
-- just to put an empty statement at the beginning of the end file.

Thus the site's combined file won't be globally strict, however since a lib
is tested before a production release (at least I hope so ;), then the lib's
code should pass the strictness, and therefore, a "use strict" may be even
removed from the lib's file. However, if not to remove, then an empty
statement is enough.

;/*1st lib*/"use strict";eval = 10;/*2st lib*/"use
strict";arguments=20;/*our code*/

Dmitry.


> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100909/f62e1ddf/attachment.html>


More information about the es-discuss mailing list