Jian Lin
2010-Jun-12 10:49 UTC
How not to include the same javascript files more than once?
In Ruby on Rails, if a partial (such as _msgbox.html.erb) need to use Javascript by javascript_include_tag :defaults but then, the page layout or other view may also have that same line, so the same javascript files will be included multiple time? Is there a way to tell Rails just to include it at most once? kind of like the PHP ways of require_once or include_once -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jun-12 16:31 UTC
Re: How not to include the same javascript files more than o
Jian Lin wrote:> In Ruby on Rails, if a partial (such as _msgbox.html.erb) need to use > Javascript by > > javascript_include_tag :defaults > > but then, the page layout or other view may also have that same line, so > the same javascript files will be included multiple time? > > Is there a way to tell Rails just to include it at most once? kind of > like the PHP ways of require_once or include_onceYou needn''t worry about this. The browser''s caching mechanism should ensure that the file is only fetched once. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.