Loading jQuery in magento only if it was not loaded before

0

I need my module to only load jQuery if it has not yet loaded on the page, I did it by javascript, but it runs very fast, even using 'setInterval' and so on .. In some cases they keeps going without waiting for jQuery load, my question would be:

How can I load jQuery with my module only if it was not loaded before?

    
asked by anonymous 09.04.2014 / 16:07

1 answer

1

I found a script in the SOEN that can help you, try adding this script block to the page that needs to perform the validation:

<script>
if(!window.jQuery) // verifica se foi carregado
{
   var script = document.createElement('script');
   script.type = "text/javascript";
   script.src = "path/to/jQuery"; //caminho para carregar
   document.getElementsByTagName('head')[0].appendChild(script); // adiciona script no HEAD
}
</script>
    
09.04.2014 / 16:21