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

Jian L. 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_once

You 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
[email protected]