Externalise some JS so it can be cached
Insert JS very late to better cope if jQuery has been pushed down