I'm using bits of javascript on my website for an image gallery, smooth scrolling, etc. These scripts are not used on every page (not every page has an image gallery for example). However, the scripts aren't very big and most users will have to download them eventually (the image gallery is very central to the website).
Now what would be the pros and cons of these two (mutually exclusive) ways of including the scripts:
- add them to every page (so that they'll all be cached after one page view)
- add them only on the pages on which they are used (so they're cached only when they're needed, but some pages will take a little longer)?
I'm not asking for opinions, I'd just like to know if there are any pros and cons I've overlooked.