It appears ABSOLUTE filespecs to external files work for CSS (addLinkRel
) but not JS (addJs
). The sytem always prepends the site domain+path when using addJs
.
<layout version="1.0.0">
<adminhtml_mypage_index>
<reference name="head">
<action method="addJs">
<!-- This does not work ... -->
<name>//cdn.... .js</name>
</action>
<action method="addLinkRel">
<!-- ... but this does! -->
<rel>stylesheet</rel>
<href>//cdn.... .css</href>
</action>
This forces me to a confusing inconsistency whereby the CSS files on, say a CDN, can be specified declaratively in the layout .xml, but the associated external JS files on the same CDN need to go in the .phtml. Is there a better way?
One would hope one could could keep these file references together in a logical place.
Should I move both the JS and CSS declarations from the layout .xml to the associated .phtml so that they're kept together? One could argue this then defeats the purpose of using .xml to declaratively specify JS and CSS.
Suggestions?