Choosing a JavaScript Asynch-Loader [closed]
https://softwareengineering.stackexchange.com/questions/76619
-
01-11-2019 - |
题
I’ve been looking at various asynchronous resource-loaders and I’m not sure which one to use yet. Where I work we have disparate group-efforts whose class-modules may use different versions of jQuery (etc). As such, nested dependencies may differ, as well. I have no control over this, so this means I need to dynamically load resources which may use alternate versions of the same library.
As such, here are my requirements:
- Load JavaScript and CSS resource files asynchronously.
- Manage dependency-order and nested-dependencies across versions.
- Detect if a resource is already loaded.
- Must allow for cross-domain loading (CDN's)
- (optional) Allow us to unload a resource.
I’ve been looking at:
I might be able to fake these requirements myself by loading versions into properly-namespaced variables & using an array to track what is already loaded...but (hopefully) someone has already invented this.
So my questions are:
- Which ones do you use? And why?
- Are there others that my satisfy my requirements fully?
- Which do you find most eloquent and easiest to work with? And why?
UPDATE:
For those interested, I tried all the AMD libraries above (and more). In the end, I went with RequireJS. It's just cleaner and easier overall...and I'm glad to be using it.
没有正确的解决方案