问题描述
我想尝试插入JavaScript原型的异步属性在Magento 1.9.1脚本
标签:
I would like to try to insert the "async" attribute in Prototype JavaScript script
tag in Magento 1.9.1:
<script type="text/javascript" src="http://www.mywebsite.com/media/js/ec1651c8b1a4ea49a916679f1e120ccf.js"></script>
我会有这样的结果:
I would have this result:
<script type="text/javascript" src="http://www.mywebsite.com/media/js/ec1651c8b1a4ea49a916679f1e120ccf.js" async></script>
在哪里我必须插入异步?什么跟这一行code中的文件?
谢谢
Where I have to insert "async"? What is the file with this line code?Thanks
推荐答案
看一下文件应用程序/设计/前端/&LT; yourlayout&GT; /&LT; yourtheme&GT; /layout/page.xml
(或复制应用程序/设计/前端/基/默认/布局/ page.xml
到你的主题)。
Look at the file app/design/frontend/<yourlayout>/<yourtheme>/layout/page.xml
(or copy app/design/frontend/base/default/layout/page.xml
into your theme).
在这个文件中,搜索以下行:
Inside this file, search for the following lines:
<!-- ... -->
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script></action>
<!-- ... -->
</block>
<!-- ... -->
和变化 addJs
通过调用:
<!-- ... -->
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script><params>async</params></action>
<!-- ... -->
</block>
<!-- ... -->
当你正在使用JavaScript的Magento的功能,你需要应用此更改到每个 addJs
定义的合并,因为Magento的意愿组文件PARAMS
。
As your are using the merging javascript feature of magento, you need to apply this change to every addJs
definition, because Magento will group files by params
.
这篇关于HTML&LT;脚本&GT;在Magento异步属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!