How to load a JavaScript file into a Joomla PHP page.


URL of the JavaScript file is contained in the $url variable.

$url = "components/com_mycomponent/assets/js/script.js";

Méthode 1 : JHtml (recommended)

JHtml::script($url, false);

Méthode 2 : JDocument (older, limited)

$document = JFactory::getDocument();

See also:



Keep Me Informed

Keep me informed of the latest extensions releases and offers. One email maximum per month.

Offer Me A Coffee!

If you like my work, offer me a coffee! Nick.