3 ms·
Yep, this is the race condition that the author was referring to. RequireJs also let's you express these dependencies, but will block behind the cssdom due to
by thehandofkwll 9y ago
Yep, this is the race condition that the author was referring to.
RequireJs also let's you express these dependencies, but will block behind the cssdom due to the way it injects.
Actually, I made a little library which let's you manage dependencies with script async or defer, and can be considered an alternative to the authors (neat) solution. https://github.com/bohdyone/adm.js https://github.com/bohdyone/adm.js
- lewisjoe 9y agoCurious question: Can you explain a bit more on "will block behind the cssdom due to the way it injects" As far as I know, requireJS doesn't do XHR requests and evals. That sounds ugly. I think it dynamically injects a script tag and loads the module. I maybe wrong. Either way, how's it a blocking one? So, the only thing that makes fetchInject, differ from requireJS is the non-blocking way. Is my understanding correct?
- dgoldstein0 9y agoalso wondering about the cssom comment. I can confirm that requirejs works by injecting <script> tags - <script async> to be precise. requirejs' api isn't promise based, but that's mostly an aesthetic concern. btw you seem to imply that requirejs blocks - what do you mean by that?
- thehandofkwll 9y agoThis article by an engineer at Google explains it pretty well. My own testing has shown the same results. https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/ https://www.igvita.com/2014/05/20/script-injected-async-scri...