I figured putting it inline at the bottom of the page would be the fastest way to load, but I read on the web that big inline JS functions can occasionally mess with the HTML, and loading them externally is the way to go. Of course, all this advice is from web designers who take caching and web design standards into account, none of which apply to me.
So what do you guys do with your JS functions?
I recently put mine in an external js file, based on comments I got from Google’s page speed test results:
Don’t have my own data on whether it’s improved load time though
Very much depends on what you’re doing, as other people have mentioned – and particularly, which big libraries you’re loading.
If you’re running JQuery, for example, you DEFINITELY want that loading from Google’s mirrors, not your own site.
Yeah I probably should’ve been more specific about what exactly I’m loading.
I already got jquery loading from google’s libraries
The rest are just a couple scripts for basic adult LP tricks- a countdown timer, a script to make the fake loading bar and move words around on the screen, etc. Nothing too crazy.
OK, those should be fine if you load them inline in the footer, unless you’re doing something particularly unusual.
Inline will work better unless you’re using a large library, because the browser doesn’t have to open a second connection or do a DNS lookup. It’s a latency vs bandwidth issue.