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

felix felix8a at gmail.com
Wed Sep 8 19:08:18 PDT 2010


On 9/8/10 18:52, Brendan Eich wrote:
> There's no easy way to support concatenation and "use strict" (or private x). But the "ease" of concatenative programming in JS is an illusion already. Accumulating properties in the global object is a constant source of bugs and confusion. Modern JS libraries minimize their global binding sets.

right.  but it's common for sites to develop with separate js scripts as 
"modules" and then combine them into a single script for speed when 
deployed to end-users.  global conflicts can be found and solved when 
the js scripts are included separately, and naive concatenation does not 
change how the scripts behave.

except file-level directives like "use script" change that.  now I need 
to either
- test the concatenation.
- use a smarter rewriting-concatenator, which is probably complex enough 
that the result will need testing anyway.
- validate the individual js files as naive-concatenation-safe before 
doing the concatenation.

this probably should happen even if I use the module-with-exports 
pattern in my code, since who knows if some other js lib I use has 
file-level directives or not, and it's no fun to inspect it manually on 
every update.


More information about the es-discuss mailing list