# Is it too late to put stuff in the head?

**URL:** <https://www.ruby-forum.com/t/is-it-too-late-to-put-stuff-in-the-head/90931>\
**Category:** Rails\
**Created:** [April 3, 2007, 3:11am UTC](https://www.ruby-forum.com/t/is-it-too-late-to-put-stuff-in-the-head/90931 "2007-04-03T03:11:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfwalter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/278dde/32.png) [@sfwalter](https://www.ruby-forum.com/u/sfwalter)\
**Post date:** [April 3, 2007, 3:11am UTC](https://www.ruby-forum.com/t/is-it-too-late-to-put-stuff-in-the-head/90931/1 "2007-04-03T03:11:07Z")

</div>

Hi,

I am using layouts and I have one my controller actions include a  
javascript tag. Is it possible to get the javascript tag thats part  
of the controller’s view .rhtml to be put into the head tag instead  
of the body? Or is it to late and I just have to live with having  
javascript tags in the body?

Thanks in advance. Scott.

---

<div class="post-metadata">

**Author:** ![sfwalter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/278dde/32.png) [@sfwalter](https://www.ruby-forum.com/u/sfwalter)\
**Post date:** [April 3, 2007, 3:47am UTC](https://www.ruby-forum.com/t/is-it-too-late-to-put-stuff-in-the-head/90931/2 "2007-04-03T03:47:09Z")

</div>

I wrote a very simple plugin for this a while ago.

You can find it at  
[http://agilewebdevelopment.com/plugins/resource\_on\_demand](http://agilewebdevelopment.com/plugins/resource_on_demand)

---

<div class="post-metadata">

**Author:** ![sfwalter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/278dde/32.png) [@sfwalter](https://www.ruby-forum.com/u/sfwalter)\
**Post date:** [April 3, 2007, 4:52am UTC](https://www.ruby-forum.com/t/is-it-too-late-to-put-stuff-in-the-head/90931/3 "2007-04-03T04:52:12Z")

</div>

In your layout:

\<%= yield :extra\_head\_content %\> ...

In your view:

\<% content\_for :extra\_head\_content do %\>  
\<%= javascript\_include\_tag ‘whatever’ %\>  
\<% end %\>

WDYT?

Scott W.-2 wrote:

> Thanks in advance. Scott.
> 
> >

–  
View this message in context:  
[http://www.nabble.com/Is-it-too-late-to-put-stuff-in-the-head--tf3509250.html#a9802865](http://www.nabble.com/Is-it-too-late-to-put-stuff-in-the-head--tf3509250.html#a9802865)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![sfwalter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/278dde/32.png) [@sfwalter](https://www.ruby-forum.com/u/sfwalter)\
**Post date:** [April 3, 2007, 2:32pm UTC](https://www.ruby-forum.com/t/is-it-too-late-to-put-stuff-in-the-head/90931/4 "2007-04-03T14:32:25Z")

</div>

Perfect and very elegant!
