On Wednesday, November 18, 2015 at 4:43:09 PM UTC-5, John English wrote: > > On Tuesday, November 17, 2015 at 7:17:00 PM UTC+2, Aria Stewart wrote: > >> Indeed that is difficult: the way most people solve it now is with >> webpack or browserify, where the requires are done statically, at build >> time, not at runtime. There's a few modules where that won't work, but for >> the most part it's a workable way. >> >> OK. I was trying to do it on-the-fly, but I suppose I could look at just > bundling everything up, or maybe have different bundles for different > situations, or... (sigh). > > >> You really don't want to be blocking the browser interaction thread, so >> synchronous is in fact not good there (though you're likely only doing it >> at startup time), and requests have a real cost in latency, especially >> unparallelized like a synchronous interface will allow you to do. >> > > The only other ideas I had were > (a) to fork it off into a separate thread (which I could do easily in > Java, but in JS... maybe use setTimeout? I don't know enough about the JS > threading model) > (b) write my own version of "require" which injects a <script> node into > the DOM tree and let the browser do the loading rather than using XHR... > > Yeah, there are no threads available.
There may be clever options available with Service Workers in some browsers, but that's bleeding edge stuff. And in any case, _any_ asynchronous interface in node is going to have a different interface than a sync one -- the limitation is in the synchronous interface. require.js is similar concepts to node's require, but fully asynchronous. I find it complex and that browserify is a better trade-off for me. > Either way it seems I would have to figure out a way to notify the main > thread when things were ready to roll. (More sighs,) > > Does any of this sound remotely practical? > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/f5c16ace-aee8-46c7-bf78-9b7d294c365c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
