JSFiddle - React, Tailwind, and code Playground
JavaScript
//jQuery is load by js fiddle already .
//Note: I don't want to create two script file , using code snippets instead. ;)
//----------pluginA.js-------------------------
(function($,undefined){
$.fn.mask = function (){
$(document.body).append("pluginA mask <br />");
}
})(jQuery);
//----------pluginA.js-------------------------
//change jQuery mapping
window.origJQuery = window.jQuery;
window.jQuery = $.sub(); //Create a new jQuery context
$(document.body).append("If the jQuery.fn.mask exist after sub : "+(jQuery.fn.mask != null)+" <br />");
//----------pluginB.js-------------------------
(function($,undefined){
$.fn.mask = function (){ //jQuery.fn.mask is overwrited again,but it will only apply to sub() one .
$(document.body).append("pluginB mask <br />");
}
})(jQuery);
//----------pluginB.js-------------------------
var $b = window.jQuery;
window.jQuery = window.origJQuery;
$(document.body).mask(); //we don't change the $ reference , so it's origJQuery with mask in pluginA .
$b(document.body).mask(); //it's sub() one, will call the mask in plugingB .