On 13/10/2013, at 21:34, Brendan Eich wrote:
> Jorge Chamorro wrote:
>>
>> Are main.js and assets.zip two separate files, or is main.js expected to
>> come from into assets.zip?
>
> The latter.
>
>> I think the latter would be best because it would guarantee that the assets
>> are there by the time main.js runs, as if they were local files, ready to be
>> require()d synchronously.
>
> How would old browsers cope, though? They would load only lib/main.js (and
> possibly make a request storm, as Russell brought out elsewhere in this
> thread), so (synchronous) require of another member of assets.zip might or
> might not work.
Exactly.
The only 'fix' that I can think of is to use sync XHRs (I know, I know...). For
example this code would run fine in any browser, with or without .zip packages:
```
function require (modulo) {
if (!require.modulos) {
require.modulos= Object.create(null);
}
if (!(modulo in require.modulos)) {
var xhr= new XMLHttpRequest();
xhr.open('GET', modulo, false);
xhr.send();
require.modulos[modulo]= Function('require', xhr.responseText)(require);
}
return require.modulos[modulo];
}
require('js/main.js');
```
Only much slower in old browsers, but lightning fast with .zip packages (if you
choose wisely what you put into the .zip package).
> A prefetching <link> element might not suffice in old browsers, I'm pretty
> sure it won't.
>
> If the only way to cope with downrev browsers is to use Traceur, so be it. We
> just need to be sure we're not missing some clever alternative.
I for one don't have any better ideas, sorry.
Thank you,
--
( Jorge )();
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss