AFAICT using async defer, one cannot express "you need to load X.js and Y.js before running Z.js, and you need to load X.js and A.js before running B.js". It looks like fetchInject allows you to express that type of thing.
But how is this different from RequireJS? I think RequireJS uses XHR and I don't think it supports CSS, but aside from that, what's new? I feel like this is just reinventing AMD.
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
Curious 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?
also 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?
This seems to be a lot simpler in scope. RequireJS allows you to essentially do dependency injection, whereas this doesn't handle that. It also uses the fetch API rather than plain XHR as well as using and returning native promises when fetching libraries. I think it's primarily for loading resources from a different server, like a CDN, in arbitrary but definable order, and that's it.
requirejs doesn't natively support css, but it has a pretty easy to use loader api so it'd be easy to add css support and in fact one already exists: https://github.com/guybedford/require-css
But how is this different from RequireJS? I think RequireJS uses XHR and I don't think it supports CSS, but aside from that, what's new? I feel like this is just reinventing AMD.