Question

I need my module just do load jQuery if it has not loaded before, I did the javascript, but it runs very fast and even using 'setInterval' etc. .. and in some cases they still going without waiting for jquery load my question would be, how can I load jQuery to my module only if it was not loaded before?

Was it helpful?

Solution

I think you can solve this way. But i think this is dirty way to achieve this

I check in head.phtml and its working for me

<?php
    $jsget= $this->getCssJsHtml();//all magento js/css store in $jsget variable
    $jquertcheck=strpos($jsget, 'jquery');

//and check with jquery word contain or not or you can find more possibility qith jquery word

Where $this is Mage_Page_Block_Html_Head block

if($jquertcheck==false) { ?>

// if it doesn't contain jquery word then you can include jquery

<script src="<?php echo $this->getSkinUrl("js")?>/jquery.js" type="text/javascript"></script>
<?php
}

?>

Let me know if it works or not .

I think someone can post other solution to achieve this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top