public method

Returns a JavaScript include tag (<script /> element). If the filename is prefixed with '/', the path will be relative to the base path of your application. Otherwise, the path will be relative to your JavaScript path, usually webroot/js.


  • mixed $path

    String The name of a JavaScript file, or an array of names.

  • array $options

    Available options are:

    • 'inline' boolean: Whether or not the <script /> element should be output inline. When set to false, the scripts() handler prints out the script, and other specified scripts to be included in the layout. Defaults to true. This is useful when page-specific scripts are created inline in the page, and you'd like to place them in the <head /> along with your other scripts.
    • any other options specified are rendered as HTML attributes of the element.




This method can be filtered.


	public function script($path, array $options = []) {
		$defaults = ['inline' => true];
		list($scope, $options) = $this->_options($defaults, $options);

		if (is_array($path)) {
			foreach ($path as $i => $item) {
				$path[$i] = $this->script($item, $scope);
			return ($scope['inline']) ? join("\n\t", $path) . "\n" : null;
		$m = __METHOD__;
		$params = compact('path', 'options');

		$script = Filters::run($this, __FUNCTION__, $params, function($params) use ($m) {
			return $this->_render($m, 'script', $params);
		if ($scope['inline']) {
			return $script;
		if ($this->_context) {