From Joomla! Documentation

Revision as of 11:40, 21 May 2014 by Sovainfo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Adds the definition of a linked external script to the document object. Duplicates are ignored.


void addScript( $url, $type )


Argument Data type Description Default
$url string URL of script.
$type string MIME type of script. 'text/javascript'


To add a link to some JavaScript code at a specific URL, you could use:

$doc =& JFactory::getDocument();

How this is rendered depends on the document type. If the document type is HTML then this code will produce following link in the HTML HEAD section:

<script type="text/javascript" src=""></script>

See also