Yii Framework Forum: Asset and other JS files included before title - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Asset and other JS files included before title Rate Topic: -----

#1 User is offline   iYii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 12-April 12

Posted 12 April 2012 - 06:08 PM

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)?
1

#2 User is offline   karminski 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 19-April 12
  • Location:Moscow, Russia

Posted 15 May 2012 - 03:31 AM

View PostiYii, on 12 April 2012 - 06:08 PM, said:

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.

0

#3 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 15 May 2012 - 04:04 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users