Home / Frontend Codes and Demos / CMS / Joomla / Add custom attribute in Joomla 3.x addScript
Add custom attribute in Joomla addScript

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

Add custom attribute in Joomla 3.x addScript

Add custom attribute in Joomla 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

About CV

I'm frontend developer

Check Also

How to override layouts in Joomla 3?

how to overrides joomla 3 layouts

Joomla has the option to override the Modules, Components and Layouts. This article will help you, how to override the joomla3 layouts. Here we can override the layouts in two ways. One is via Joomla 3 administrator and another way is manual, copy paste the file. We can see both way of overriding the layouts.