Putting script code to the end of POS_END


in my layout/main.php I am registering scripts for facebook and google+ AFTER the $content part. But these scripts are still in the very top of POS_END and blocking the execution of scripts coming after these parts.

So it seems first all scripts in main.php are included and then any scripts included by nested templates.

So how can one register scripts in main.php and force them to the very end of POS_END?



We implemented a custom CClientScript when we had the same problem with POS_READY. We needed to have our script run after Yii did their stuff.

Basically we just made up a new constant in our subclass called POS_READ_LATE and implemented support for that. CClientScript can be overridden in config. Reply if you need additional details. Also, if you find a more clever way, please share :)

It seems we will do pretty the same. I have created a feature request here.