Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created October 29, 2013 00:52
Show Gist options
  • Save Raynos/7207449 to your computer and use it in GitHub Desktop.
Save Raynos/7207449 to your computer and use it in GitHub Desktop.

AMD Pros

  • No build step
  • CORS loading of modules
  • etc...

No build step.

Genuine use case. I appreciate that.

However in some / most cases having an optimizing build step is worth while, in those cases you have a build step anyway so the advantage is lost.

CORS loading of modules

Unless your loading say https://amdjs.org/jquery/2.1.3 loading arbitrary scripts at arbitrary versions is very dangerous. Having hard experience with dependending on semver ranges in node & browserify, patch version changes break back compat some times which lead to production bugs at arbitrary times.

Hence fixing versions is worthwhile.

If your going to load [email protected] remotely over CORS then you could also have loaded it locally because it exists and you can download and bundle it.

One valid use case to do this is a shared CDN to take advantage of CORS caching shared among many users. This again is only valid for modules that are popular and is an exception to the norm.

@domenic
Copy link

domenic commented Oct 29, 2013

"CORS loading of modules" is a bit misstated. The only use-case AMD solves in this regard:

  • Loading of modules from other domains
  • Which don't have CORS enable for those resources
  • And have been prepackaged as AMD format

Any CDN should probably be enabling CORS for resources it wants people to be able to load from other domains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment