Managing position of scripts

By default CClientScript provide us with ability to register scripts in different predefined parts of documents. It would be great if I had ability to point where to place a code in my document.

Like this maybe (layout)




<script type='text/javascript' src='/myscript.js'></script>

<?php Yii::app()->clientScript->setPosition('after_my_scripts'); ?>



What do you think?


You can place your css/js script anywhere inside the view file like so:

$am = Yii::app()->getComponent('assetManager');

$cssUrl = $am->publish('mydirectory/my.css');

$jsUrl = $am->publish('mydirectory/my.js');

This will automatically move published file into assest directory and return public URL,

which you can include anywhere in yoru script. You dont have to use clientScript, which has predefined positions.