jQuery.noConflict() | Avoiding Conflicts with Other Libraries
by Pritom K Mondal
JavaScript
(function() {
function loadJQuery() {
var startingTime = new Date().getTime();
var script = document.createElement("SCRIPT");
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
script.type = 'text/javascript';
script.onload = function() {
var $j = jQuery.noConflict();
jQuery = $;
$(function() {
var endingTime = new Date().getTime();
var tookTime = endingTime - startingTime;
window.alert("jQuery previous version=" + $.fn.jquery + ", version=" + $j.fn.jquery);
});
};
document.getElementsByTagName("head")[0].appendChild(script);
}
loadJQuery();
})();