Php Require.js和Zend框架
在Zend框架中包含Require.js的最佳方式是什么?我目前在zend framework中调用js文件的方式如下:Php Require.js和Zend框架,php,jquery,zend-framework,requirejs,Php,Jquery,Zend Framework,Requirejs,在Zend框架中包含Require.js的最佳方式是什么?我目前在zend framework中调用js文件的方式如下: <?php echo $this->jQuery()->setLocalPath($this->path('js/jquery/jquery-1.7.1.min.js')) ->enable() ->setUiLocalPath($this->path('js/jquery/jquery-ui-1.8.16.custo
<?php echo $this->jQuery()->setLocalPath($this->path('js/jquery/jquery-1.7.1.min.js'))
->enable()
->setUiLocalPath($this->path('js/jquery/jquery-ui-1.8.16.custom.min.js'))
->uiEnable()
->addStylesheet($this->path('css/jquery/jquery-ui-1.8.16.custom.css'));
echo $this->headScript()->appendFile($this->path('js/jquery.tipTip.js'))
->appendFile($this->path('js/customScripts/facebook.js'))
->appendFile($this->path('js/facebook/jquery.facebook.multifriend.select.js'))
->appendFile($this->path('js/customScripts/logindialog.js'))
->appendFile($this->path('js/customScripts/globalFunctions.js'))
->appendFile($this->path('js/kendo.web.min.js'))
->appendFile($this->path('js/customScripts/fancyAlert.js'))
->appendFile($this->path('js/inc/jquery.mousewheel.min.js'))
->appendFile($this->path('js/pagination-jq.js'))
->appendFile($this->path('js/jquery.tools.min.js'))
->appendFile($this->path('js/fancybox/jquery.fancybox-1.3.4.pack.js'))
->appendFile($this->path('js/jq-history/scripts/jquery.history.min.js'));
?>
使用require.js,您只需向头部添加一个脚本文件(或在关闭
之前)
然后,在require.js配置文件和模块中,您将实际定义每个模块的依赖项
在您的情况下,我将手动添加脚本文件:
<script src="require.js" data-main="path/to/mainScriptFile"></script>
但在这一点上,只需手动输入一个脚本标记,就可以减少开销
希望这有帮助 在html文件中,您可以在
标记之间添加一行。这是最好的方法
<script src="/path/to/require.js"></script>
或者您可以使用jquery
var jsScript = $("<script src='/path/to/require.js'></script>");
$('body').append(txt2);
var jsScript=$(“”);
$('body')。追加(txt2);
这将在正文的底部附加js您可以看到这样的包含,难怪我访问的大多数页面都比pond water慢,而这一页也没那么糟糕(
var jsScript = $("<script src='/path/to/require.js'></script>");
$('body').append(txt2);