How to ensure that your script runs first in a webpage

Sam Tobin-Hochstadt samth at
Sat Feb 4 20:23:14 PST 2012

On Sat, Feb 4, 2012 at 1:02 PM, David Bruant <bruant.d at> wrote:
> Le 04/02/2012 18:14, Mark S. Miller a écrit :
>> c) The ES6 module loader should make all these with-games unnecessary
>> anyhow, since it gives us a principled approach for controlling the
>> top level scope of untrusted code. Long term, this is the real answer.
> Ok, good to know.
> Can you show how "eval(string, lexEnv)" example would look like with
> module loaders? The proposal [1] (and the entire web?) lacks a bit of
> examples.

There's an examples page which includes some module loaders examples
(although not this one) [1].

I'm imagining that |lexEnv| is the entire environment that you want
available for this evaluation, ie, it shouldn't see any other
bindings.  For this, we'd do the following:

  let l = new Loader(system /* the parent loader */,
                            null /* make fresh intrinsics */,
                            lexEnv /* use lexEnv as the global scope */);

Note that this is slightly different than the API currently described
on the web page; Dave and I have updates that we need to make there.

sam th
samth at

More information about the es-discuss mailing list