开发者

stop joomla 1.5 loading jquery twice

开发者 https://www.devze.com 2023-01-17 20:45 出处:网络
i have a custom joomla template which i load jquery in using the normal <script></script>tages.I have installed a plugin which also loads jquery, meaning that jquery is being loaded twice.

i have a custom joomla template which i load jquery in using the normal <script></script> tages. I have installed a plugin which also loads jquery, meaning that jquery is being loaded twice. the plug in is only loaded on a few pages but i require jquery on every page so can't take it out the template. what is the best way to stop it load开发者_JAVA百科ing jquery twice?


Use this javascript code///

if (typeof jQuery == 'undefined') {   
    var head = document.getElementsByTagName("head")[0]; 
   script = document.createElement('script'); 
   script.id = 'jQuery'; 
   script.type = 'text/javascript'; 
   script.src = 'js/jquery.js'; 
   head.appendChild(script); 
} else { 
    // jQuery is loaded already need not include it...

}

typeOf operator checks if the jQuery object already exists if it does not exist then create a script element and append it to head of the html.

0

精彩评论

暂无评论...
验证码 换一张
取 消