Back to Document class

Method addScriptDeclaration

public \Joomla\CMS\Document\Document
addScriptDeclaration
(mixed $content, mixed $type = 'text/javascript')
Adds a script to the page
Parameters
  • string $content Script
  • string $type Scripting mime (defaults to 'text/javascript')
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Deprecated
  • 5.0
Class: Document
Project: Joomla

Method addScriptDeclaration - Source code

/**
 * Adds a script to the page
 *
 * @param   string  $content  Script
 * @param   string  $type     Scripting mime (defaults to 'text/javascript')
 *
 * @return  Document instance of $this to allow chaining
 *
 * @since   1.7.0
 *
 * @deprecated 5.0  Use WebAssetManager
 */
public function addScriptDeclaration($content, $type = 'text/javascript')
{
    $type = strtolower($type);
    if (empty($this->_script[$type])) {
        $this->_script[$type] = array();
    }
    $this->_script[$type][md5($content)] = $content;
    return $this;
}