// MOCKUP // Declaring a package $.provide('some.plugin', function($) { // $: an isolated instance of jQuery $.Static = {}; // jQuery plugin $.fn.func1 = function(){alert(1);}; $.fn.func2 = function(){this.func1();}; }); //Declaring another package $.provide('some.other.plugin', function($) { // $ is another jQuery instance $.fn.func1 = function(){alert(2)}; }); $('div').func1() //error, it doesn't exist // Running jQuery in a private scope $.run(function($){ $.using('some.plugin.*'); // Importing properties // We have the Variable now alert($.Static); // Still doesn't exist $('div').func1(); }); // Another scope $.run(function($){ $.plugin('some.plugin.*'); // importing plugin $('div').func2(); // now it exists }); // Another scope $.run(function($){ $.plugin('some.plugin.*'); // importing plugin $.plugin('some.other.plugin.*'); // importing other plugin $('div').func1(); //Alert 2 $('div').func2(); // Alert 1, works without conflict });