Add custom attribute in Joomla 3.x addScript

This tutorial will explain you, how add custom attributes in Joomla 3.x addScript()

Find the code below

$doc = JFactory::getDocument(); 
$doc->addScript(JURI::root(true) . '/libraries/gantry/libs/google-code-prettify/prettify.js', array(), array('data-cfasync' => 'false'));

Find the detailed explanation about the above code.

Before calling addScript() have to call JFactory::getDocument() like below.

$doc = JFactory::getDocument();

$doc->addScript(url, version, attributes); addScript has three parameters 1st url, 2nd Version and 3rd attributes.

Find the demo image below

joomla add custom attributes in addscript
Demo Image: joomla add custom attributes in addscript
Categories:
W3TWEAKS
Latest posts by W3TWEAKS (see all)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *