Assets

  • I just want to point out, what the tilde actually does when used as prefix to dependencies in $scrips->register() on view.scripts or $styles->register() on view.styles. I always forgot it and was unsure about, what it actually does as it is not clearly (or exactly) explained in the docs.

    Code
    1. 'view.scripts' => function ($event, $scripts) {
    2. $scripts->register('my-script','path/to/script.js,[uikit, ~widget]);
    3. }

    my-script is loaded after uikit and after the script which is registered with widget.


    But with using tilde ~ as prefix for widget, my-script only gets loaded, if widget get's loaded. This fact Isn't explicitly stated in the docs.


    If use it via the Script and Stylehelper, the ~ has no affect, as $view->style() or $view->script() uses the add() method of the AssetManager which does't consider ~.


    Hope this helps somebody.

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

    Edited 6 times, last by SAB ().