Results 1 to 6 of 6

Thread: What are the drawbacks of using Javascript?

  1. #1
    Join Date
    Dec 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default What are the drawbacks of using Javascript?

    I've heard many people say that there are disadvantages of using multiple javascripts on a single page. Is that true? I mean can I have two scripts main11.js and main2.js run on the same page or is there some kind of restriction?

    One more question is: Does too much of Javascript spoil the fun?
    Last edited by purifier; 12-14-2006 at 07:26 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,951
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Javascript is a bit like images. Too many scripts and the page is overloaded, takes too long to load on many systems, that sort of thing. In addition, more than one script on a page can conflict for various reasons causing one, the other or both scripts not to work. These conflicts can almost always be worked out but, even then it can sometimes be quite a complex task to do so. Another drawback to javascript is that some folks may not be using it so, it really shouldn't be an essential part of the page. This last bit isn't so important these days as the vast majority of folks are using javascript. Prudent design can and should provide fall backs for non-javascript enabled browsers.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank You Sir. So conflicts in the sense, global and local variable conflicts? And suppose that I include a js file in the html of a page. Is it fetched even before it is required or will it be fetched after an event is triggered? I mean if i wrote something like <script src="main.js"> will main.js be fectched before there is a function reference?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,951
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Global variables, yes. Functions, objects and elements too.

    All scripts on or linked to a page are loaded as the page loads, even if they are never used on the page. However, once an external script is loaded, it is cached so, will not need to be loaded for other pages that it is linked to, at least until it is removed from the cache.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Dec 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh.. so maybe that is the reason a website takes time when loading for the first time and then speeds up... Thank You Sir...

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I had a JS clock on my main page. just a tiny 4 line code. My main page took 12 to 22 seconds to display. I removed that single script, and my page now loads in 1 to 2 seconds.

    Servers are weird. ROTF
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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
  •