Last active
November 15, 2016 13:51
-
-
Save davearel/9254418 to your computer and use it in GitHub Desktop.
jQuery AMD example, regarding: https://tech.bellycard.com/blog/the-future-of-jquery/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
// jquery core is always required | |
'jquery/core', | |
// jquery utilities | |
'jquery/ajax', | |
'jquery/data' | |
], function(jq, ajax, data) { | |
// Using the core module, create a jQuery instance | |
// with the required extensions | |
var $ = jq.require(ajax, data); | |
// The local instance of $ contains the necessary jQuery | |
// extensions, but once this module is done executing, | |
// "$" no longer exists to other modules. | |
}); |
I'd break them apart and leave them apart personally, things like requests have no place in jquery proper IMO
I agree with @visionmedia's point, but I don't see that happening.
Conversation has migrated to: https://gist.github.com/tbranyen/9255362
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, I'm sure this isn't as easy as it appears. I completely understand that. Some of the core internal concepts may have to change. There wouldn't be an initial feature detect for every new instance, this should only happen once.
The point is not that the instances are completely segregated (data stores, etc, may be accessible from all instances), the idea is that the API is only accessible if required, and in the end only gets included in the production source if necessary.
There would be no conflicts, because there would be no global object.