Yii Framework Forum: Option to put registered scripts in footer, or where you would like - Yii Framework Forum

Jump to content

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

Option to put registered scripts in footer, or where you would like Rate Topic: -----

#1 User is offline   jwinn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-July 11
  • Location:Florida, USA

Posted 25 April 2012 - 11:36 PM

It's often best practice in frontend development to load JavaScript in the footer, before the closing body tag. This way, the loading of large scripts does not hold up loading of the rest of the page.

In order to do this with Yii, I've had to set the script map entries for jquery and jquery.yiiactiveform.js to false. It would be great if there was an option to have Yii place them before the closing body tag, and/or a way of manually being able to say where to place them in the template. Right now, it places before the title tag


(another very minor thing for us code indention perfectionists..if you have the tags under HEAD indented, it will screw up the indention with how it adds the code/line break in)
1

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,353
  • Joined: 12-October 09
  • Location:Croatia

Posted 26 April 2012 - 02:11 AM

Have you tried to set the coreScriptPossition - http://www.yiiframew...Position-detail
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   jwinn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-July 11
  • Location:Florida, USA

Posted 01 May 2012 - 03:18 AM

View Postmdomba, on 26 April 2012 - 02:11 AM, said:

Have you tried to set the coreScriptPossition - http://www.yiiframew...Position-detail


Can that be set globally, to apply to the JS and CSS that Yii is adding automatically? It's just a pain to keep things organized. I don't like all these extra HTTP requests, so I am trying to combine JS and CSS where I can too. I may just give in and put jQuery in the header.
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,353
  • Joined: 12-October 09
  • Location:Croatia

Posted 01 May 2012 - 04:49 AM

You can set it in the config file... note that this is only for core scripts...
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   bennouna 

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

Posted 01 May 2012 - 05:24 AM

Hello. I second that request. In my first Yii project, I didn't pay attention and I noticed too late that the scripts file that are registered automatically are put in the head, before the titleā€¦

For a current project, I ended up writing my own script tags at the end of body tag, except html5shiv of course.

@jwinn on a side note, does putting your CSS in the footer work?
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