framework/web/View.php
public function registerJsFile($url, $options = [], $key = null)
    {
        $url = Yii::getAlias($url);
        $key = $key ?: $url;

        $depends = ArrayHelper::remove($options, 'depends', []);

        if (empty($depends)) {
            $position = ArrayHelper::remove($options, 'position', self::POS_END);
            $this->jsFiles[$position][$key] = Html::jsFile($url, $options);
        } else {
            $this->getAssetManager()->bundles[$key] = Yii::createObject([
                'class' => AssetBundle::className(),
                'baseUrl' => '',
                'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')],
                'jsOptions' => $options,
                'depends' => (array) $depends,
            ]);
            $this->registerAssetBundle($key);
        }
    }
public function registerJsFile($url, $options = [], $key = null)
    {
        $url = Yii::getAlias($url);
        $key = $key ?: $url;

        $depends = ArrayHelper::remove($options, 'depends', []);

        if (empty($depends)) {
            $position = ArrayHelper::remove($options, 'position', self::POS_END);
            $this->jsFiles[$position][$key] = Html::jsFile($url, $options);
        } else {
            $this->getAssetManager()->bundles[$key] = Yii::createObject([
                'class' => AssetBundle::className(),
                'baseUrl' => '',
                'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')],
                'jsOptions' => $options,
                'depends' => (array) $depends,
            ]);
            $this->registerAssetBundle($key);
        }
    }
public function registerJsFile ( $ url , $ options = [ ] , $ key = null ) { $ url = Yii :: getAlias ( $ url ) ; $ key = $ key ? : $ url ; $ depends = ArrayHelper :: remove ( $ options , 'depends' , [ ] ) ; if ( empty ( $ depends ) ) { $ position = ArrayHelper :: remove ( $ options , 'position' , self :: POS_END ) ; $ this -> jsFiles [ $ position ] [ $ key ] = Html :: jsFile ( $ url , $ options ) ; } else { $ this -> getAssetManager ( ) -> bundles [ $ key ] = Yii :: createObject ( [ 'class' => AssetBundle :: className ( ) , 'baseUrl' => '' , 'js' => [ strncmp ( $ url , '//' , 2 ) === 0 ? $ url : ltrim ( $ url , '/' ) ] , 'jsOptions' => $ options , 'depends' => ( array ) $ depends , ] ) ; $ this -> registerAssetBundle ( $ key ) ; } }
Registers a JS file.

This method should be used for simple registration of JS files. If you want to use features of
[[AssetManager]] like appending timestamps to the URL and file publishing options, use [[AssetBundle]]
and [[registerAssetBundle()]] instead.

@param string $url the JS file to be registered.
@param array $options the HTML attributes for the script tag. The following options are specially handled
and are not treated as HTML attributes:

- `depends`: array, specifies the names of the asset bundles that this JS file depends on.
- `position`: specifies where the JS script tag should be inserted in a page. The possible values are:
* [[POS_HEAD]]: in the head section
* [[POS_BEGIN]]: at the beginning of the body section
* [[POS_END]]: at the end of the body section. This is the default value.

Please refer to [[Html::jsFile()]] for other supported options.

@param string $key the key that identifies the JS script file. If null, it will use
$url as the key. If two JS files are registered with the same key at the same position, the latter
will overwrite the former. Note that position option takes precedence, thus files registered with the same key,
but different position option will not override each other.
Registers a JS file .