Asset and other JS files included before title

Not sure if this is the right topic.

I noticed that JS files will be rendered before title tag. You can see this if you install default demo, and go to "Cotact" page. From SEO perspective, this is very bad. My goal would be to have title tag as the top most in the <head>, and then <meta> after it, and then other stuff. Could the code be adjusted/changed so JS stuff is included before the first <script> tag?

Also, how can I tweak the Yii, so JS includes are always sent at the bottom of the body (before other <script> tags)?

Hello. You do not need to tweak Yii for displaying JS at the bottom of the BODY. You can use $position parameter of the CClientScript::registerScriptFile() function which sets the position of the JS code. Valid values include the following:

  • CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.

  • CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.

  • CClientScript::POS_END : the script is inserted at the end of the body section.

It’s not the same thing. Auto-registered script files (jquery.js for instance) behave like what iYii describes. Read again, please.