NYCPHP Meetup

NYPHP.org

[nycphp-talk] JavaScript just above form in body?

John Campbell jcampbell1 at gmail.com
Wed Feb 6 17:05:08 EST 2008


> How about src-ing a .js? I've been looking at random pages and I'm
> surprised to see that not many pages actually do this. Is there a
> reason?

For non-library code, it is faster to include the javascript with the
html because it saves a web request.  For library code, it is a
trade-off... an extra web request vs loading the js from the cache
during subsequent page views.

I also think creating a js file for each page is painful.  When you
change the html you generally have to change the javascript, so why
not keep it in one place?

John C.



More information about the talk mailing list