Magento: Add external javascript or css reference link through layout xml

Use case: You want to add a jQuery UI and its css library in the head tag by referencing a cdn link in Magento.
Given: You have a layout update xml file, helloworld.xml, and in the hellowworld.xml file, you have an update handler
Code:

<hellowrold_index_index>
	<reference name="head">
		<block type="core/text" name="google.jquery.cdn">
			<action method="setText">
				<text><![CDATA[
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
                                      ]]></text>
			</action>
		</block>
	</reference>
</helloworld_index_index>

To include local javascript file or css file, see this post.

Search within Codexpedia

Custom Search

Search the entire web

Custom Search