# javascript\_include within single views

**URL:** <https://discuss.rubyonrails.org/t/javascript-include-within-single-views/37289>\
**Category:** rubyonrails-talk\
**Created:** [December 12, 2008, 2:40am UTC](https://discuss.rubyonrails.org/t/javascript-include-within-single-views/37289 "2008-12-12T02:40:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_L](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Dave\_L](https://discuss.rubyonrails.org/u/Dave_L)\
**Post date:** [December 12, 2008, 2:40am UTC](https://discuss.rubyonrails.org/t/javascript-include-within-single-views/37289/1 "2008-12-12T02:40:19Z")

</div>

Are you allowed to use the javascript\_include\_tag to include javascript files for specific views? I have included the default javascript files in the \<head\> element of my site layout file, but when I try and include a javascript file for a specific view within a new \<head\> element in that view it does not work. I guess my question is: is it okay to create separate \<head\> elements for specific views? Will all the code get rendered that is within these new \<head\> elements and the \<head\> elements in my layout file? or will there be a conflict?

---

<div class="post-metadata">

**Author:** ![Con](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Con](https://discuss.rubyonrails.org/u/Con)\
**Post date:** [December 12, 2008, 2:54am UTC](https://discuss.rubyonrails.org/t/javascript-include-within-single-views/37289/2 "2008-12-12T02:54:44Z")

</div>

Yes, you are allowed to use the javascript\_include\_tag to include javascript

files for specific view templates. Can you post your code so that people

can better assist you because I don’t follow your question.

-Conrad

---

<div class="post-metadata">

**Author:** ![Dave\_L](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Dave\_L](https://discuss.rubyonrails.org/u/Dave_L)\
**Post date:** [December 12, 2008, 7:50am UTC](https://discuss.rubyonrails.org/t/javascript-include-within-single-views/37289/3 "2008-12-12T07:50:55Z")

</div>

so would the following be redundant then?

\<% content\_for :javascript do %\> &nbsp;&nbsp;\<%= javascript\_tag "new javascript function" %\> \<% end %\>

assuming i have \<%= yield :javascript %\>

in my main layout file.
