SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    New York
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    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.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:
    Code:
    window.onload = function(){ start_countdown(); setupZoom (); }
    Tab-indentation is a crime against humanity.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by richirich View Post
    And i don't think that problem arises if scripts are kept in different .js files.
    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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •