Working with Client Scripts

Working with Client Scripts

Modern web applications, additionally to static HTML pages that are rendered and sent to the browser, contain JavaScript that is used to modify the page in the browser by manipulating existing elements or loading new content via AJAX. This section describes methods provided by Yii for adding JavaScript and CSS to a website as well as dynamically adjusting these.

Registering scripts

When working with the yii\web\View object you can dynamically register frontend scripts- There are two dedicated methods for this: