Forum Moderators: open
So lets say this file is composed of 100 functions and I develop a website that only uses 2 of the functions. Would the javascript and website be significantly quicker if I had a javascript file with ONLY those 2 functions vs. 100 functions?
I wasnt sure if file size slowed down the website speed. I realize the client would have to download the file, but downloading a javascript file with 100 functions probably wouldnt take that long at all.
Thanks for your input.
The way I would approach this is to use a bounch of functions that simply did a document.write ('function number 3') for example.
Then make a quick dummy page linked to your JS file and call the functions as you need. Preview the dummy page and it should list each of the function numbers as so. Thats how I'd approach seeing if the idea would work in the first place though again I'm still learning the syntax.
There are up and down sides to using a single js file. The upside is you save a few dosen or hundred (maybe even thousand) bytes from repeating JS includes in your HTML. The downside is if you mess up one script you may mess them ALL up.
What I would suggest then is to develope each script seperately. If you MUST test a live page, add a seperate includs and a seperate js file. Once you get it to work without any errors in target generations of Gecko, KHTML, MSIE, and Opera then add it to your master JS file and delete the temporary JS includes (if you're using a live page/site).
Hopefully someone could provide a bit more details on how exactly you could execute your idea though in an easy to replicate fashion? I am interested in this now that I think about it. :-) Best of luck!