On Thu, Mar 29, 2012 at 4:55 PM, David Herman <[email protected]> wrote:
> On Mar 29, 2012, at 4:47 PM, John J Barton wrote:
>
>> And like require.js we will have difficulty resynchronizing the script 
>> loading with document loading. For example, the above code may fail if the 
>> callback fires before 'myelement' is parsed.
>
> I'm not sure I understand. Why doesn't something like this work?
>
>    <script>
>    System.load("jquery.js", function($) {
>        $.ready(function() {
>            $('myelement').style({ 'background-color': 'yellow' })
>        });
>    })
>    </script>

To prevent a possible performance problem caused by synchronous module
loading that blocks document loading, you are proposing to enforce
asynchronous module loading.  This sets up developers for a
non-deterministic failure mode.  Not everyone uses jquery and some
that do may easily forget about the race. Can we do better?

For example if we had system.load() wait to fire the callback until
DOMContentLoaded and offered system.loadImmediate(), developers would
be altered to this issue simply by having such an API.

The example callback has two dependencies, jQuery and 'myelement'.
Only one of these has expressed to the load() operation. Perhaps there
are other ways of expressing the second dependency.

jjb

>
> Dave
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to