How many scripts on one page? Newbie wants to know

Hi folks,

I’ve been doing websites for a couple of years now, but when it comes to JavaScript, I’m still “wet behind the ears” Dumb question, but I’d sure like to know:

Is there a limit to how many different scripts I can put onto one page?

On the page in question (see link below) I’m able to get many of my scripts working, but when I try to include a “zoom” function onto the same page, it doesn’t “zoom” it just pops up onto a different page. Please feel free to “view source” the following page and tell me how I can correct this:

www.11553.com/Home.shtml.

Thank you in advance!!

Mike Dragonetti

There might be a limit, but the number would be high enough where you would never actually hit it.

Are there usage instructions that came with the script you’re referring to?

Also, a JavaScript framework, such as jQuery or prototype/scriptalicous, may help simplify things and reduce the need for extraneous scripts.

It’s the usual problem of scripts that don’t allow for the pre-existence of onload handlers.

onload=“setupZoom ()” <- Remove that from <body>

window.onload=start_countdown <- Change that to:

window.onload = function(){ start_countdown(); setupZoom (); }

No matter how much JavaScript you add to a page you still effectively only have one script since it makes no difference whether the code for your script is in one file or a million files (except that a million files would take way too long to load so you are better off combining them into as few files as possible).

The only issues you are likely to have with adding to your script is if the pieces conflict with one another. There are ways to solve those issues but it involves modifying the script to remove the conflicts.

I do not think that there is some limit to using javascripts in a page. The problem that could arise is conflict amongst these scripts. The reason behind that when you are trying to zoom, a pop up window is opening could be a state of conflict between scripts. And i don’t think that problem arises if scripts are kept in different .js files. You should test your script in a different file to make sure whether or not it is working properly.

Whether the code is in one file or separate files makes no difference. It is how the code is written that determines whether it can interfere with other code and not what file it is in.