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
Leave a Reply