Forum: Ruby on Rails Javascript include in html - load times

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E6b040ecc51de500ee5a6f83aa3adc68?d=identicon&s=25 Kfir Lavi (Guest)
on 2006-06-11 15:35
(Received via mailing list)
Hi,
If I include a javascript library, will it load when the html load, or
just at the first use?
I have table.js and I have few pages that needs it.
Should I include it just on the pages that needs it, or put it on the
application_layout?

Thanks,
Kfir
Fb23bc8cd4030c526b0689276b34c8bd?d=identicon&s=25 Bryan Duxbury (bryanduxbury)
on 2006-06-11 16:25
Kfir Lavi wrote:
> Hi,
> If I include a javascript library, will it load when the html load, or
> just at the first use?
> I have table.js and I have few pages that needs it.
> Should I include it just on the pages that needs it, or put it on the
> application_layout?
>
> Thanks,
> Kfir

Most browsers will cache a script file if its not changing, which will
be your case.

As to whether or not to put the include in every page, well, that
depends on how many of your pages actually make use of it. If its a
signficant amount of pages, then go ahead and do it. If only a few pages
use the JS, then include it directly in the .rhtml.
E6b040ecc51de500ee5a6f83aa3adc68?d=identicon&s=25 Kfir Lavi (Guest)
on 2006-06-11 17:04
(Received via mailing list)
Thanks,
I think it will be good to put it in the layout, because of the caching.

Kfir
This topic is locked and can not be replied to.