Skip to content

Instantly share code, notes, and snippets.

@davearel
Last active November 15, 2016 13:51
Show Gist options
  • Save davearel/9254418 to your computer and use it in GitHub Desktop.
Save davearel/9254418 to your computer and use it in GitHub Desktop.
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.
});
@davearel
Copy link
Author

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.

@davearel
Copy link
Author

@tj
Copy link

tj commented Feb 27, 2014

I'd break them apart and leave them apart personally, things like requests have no place in jquery proper IMO

@mikesherov
Copy link

@dmethvin, I think @davearel has a point. There is nothing stopping us from still having shared state amongst instances which all have different external Apis based on need.

@davearel
Copy link
Author

I agree with @visionmedia's point, but I don't see that happening.

@davearel
Copy link
Author

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