سؤال

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:

  1. Load JavaScript and CSS resource files asynchronously.
  2. Manage dependency-order and nested-dependencies across versions.
  3. Detect if a resource is already loaded.
  4. Must allow for cross-domain loading (CDN's)
  5. (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.

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى softwareengineering.stackexchange
scroll top