How can i add javascript file in joomla?

To add js file in joomla follow below step

$doc = JFactory::getDocument();
$doc->addScript(‘path/js/script.js’);

Add insline script

$doc = JFactory::getDocument();
$script = ‘jQuery(document).ready({
  alerlt(‘1′);
});’;
$doc->addScriptDeclaration($script);

Advertisements