Javascript 如果之前没有';我没装

Javascript 如果之前没有';我没装,javascript,php,jquery,magento,frontend,Javascript,Php,Jquery,Magento,Frontend,我需要我的模块只加载jQuery如果它以前没有加载,我做了javascript,但它运行非常快,甚至使用“setInterval”等。。在某些情况下,他们仍然不等待jquery加载。我的问题是,只有在以前没有加载jquery的情况下,我如何才能将jquery加载到我的模块中?我想你可以用这种方法解决。但我认为这是一种肮脏的方式 我签入head.phtml,它对我有效 <?php $jsget= $this->getCssJsHtml();//all magento js/cs

我需要我的模块只加载jQuery如果它以前没有加载,我做了javascript,但它运行非常快,甚至使用“setInterval”等。。在某些情况下,他们仍然不等待jquery加载。我的问题是,只有在以前没有加载jquery的情况下,我如何才能将jquery加载到我的模块中?

我想你可以用这种方法解决。但我认为这是一种肮脏的方式

我签入head.phtml,它对我有效

<?php
    $jsget= $this->getCssJsHtml();//all magento js/css store in $jsget variable
    $jquertcheck=strpos($jsget, 'jquery');
//如果它不包含
jquery
word,那么可以包含
jquery


你找到其他解决方案了吗?是的,但不是最好的解决方案
if($jquertcheck==false) { ?>
<script src="<?php echo $this->getSkinUrl("js")?>/jquery.js" type="text/javascript"></script>
<?php
}