PHPackages                             richardfan1126/yii2-js-register - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. richardfan1126/yii2-js-register

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

richardfan1126/yii2-js-register
===============================

Yii2 widget to register JS into view

v0.0.1(9y ago)1357.2k↓34.9%7MITPHP

Since Jun 29Pushed 9y ago1 watchersCompare

[ Source](https://github.com/richardfan1126/yii2-js-register)[ Packagist](https://packagist.org/packages/richardfan1126/yii2-js-register)[ RSS](/packages/richardfan1126-yii2-js-register/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (7)

yii2-js-register
================

[](#yii2-js-register)

[![Latest Stable Version](https://camo.githubusercontent.com/a6e0af5bc22710eb1c9ab37c07a0767f54ae881efab38d40079d1c6a96acdaa6/68747470733a2f2f706f7365722e707567782e6f72672f7269636861726466616e313132362f796969322d6a732d72656769737465722f762f737461626c65)](https://packagist.org/packages/richardfan1126/yii2-js-register)[![Total Downloads](https://camo.githubusercontent.com/70741492a09985d4deb4fec08c994bcfd92d34da4892a753f9eebbac9506c616/68747470733a2f2f706f7365722e707567782e6f72672f7269636861726466616e313132362f796969322d6a732d72656769737465722f646f776e6c6f616473)](https://packagist.org/packages/richardfan1126/yii2-js-register)[![GitHub stars](https://camo.githubusercontent.com/b4492da475fc97339d2f382e829b052a317cf3eac1f2702fd0d020d4c00fe8db/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7269636861726466616e313132362f796969322d6a732d72656769737465722e737667)](https://github.com/richardfan1126/yii2-js-register/stargazers)[![GitHub issues](https://camo.githubusercontent.com/4a58d34f87000c361ce0e65ade5750d8eb09a3b5b1330ce2d59f3bac413126ba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f7269636861726466616e313132362f796969322d6a732d72656769737465722e737667)](https://github.com/richardfan1126/yii2-js-register/issues)

Yii2 widget to register JS into view

Why do I need this?
-------------------

[](#why-do-i-need-this)

### How to register JS script into view in Yii2?

[](#how-to-register-js-script-into-view-in-yii2)

In Yii2, the way to register JS script into view is using \\yii\\web\\View::registerJS(),

For example, if you want to initialize a jQuery plugin, you do:

```
// in view file

        Hello World!
