SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru rageh's Avatar
    Join Date
    Apr 2006
    Location
    London, Formerly Somalia
    Posts
    612
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using getElementById() slows FireFox down?

    I have a joined form where the selection from a radio button brings up different dropdown. I am using

    Code JavaScript:
    function makechoice(choice) {
        var var1 = document.getElementById("var1");
        var var2 = document.getElementById("var2");
        if(choice.value == "var1") {
            var1.style.display='';
            var2.style.display='none';
            }
        if(choice.value == "var2") {
            var1.style.display='none';
            var2.style.display='';
          }
     
    }
    to change to bring up different dropdown each time user makes a radio button selection. I notice in FireFox things are significantly slowed down, while IE and Opera are okey.

    That is the only javaScript function I am using now. So there is no possibility that other functions may be to blame. And it is simple html file. No database loading and stuff like that. No massive images.

    My question is; does usage of getElementById() slows down FireFox? Or is it something else that is causing the slow down in FF?

    Any idea or suggestion?
    ------------------

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,268
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    slow down

    I highly doubt the getElementsById () in itself would slow down Firefox.
    Does the page load OK without any javascript at all?
    Is the HTML valid?

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Obviously, document.getElementById() wouldn't normally cause FF (or other browsers) to slow down. I'm guessing there must be something else at work here. Are you using a development version of FF by any chance? Do you have any Flash or anything else other than normal markup incorporated into the page? Can you give us a link?
    I'm available for hire! - www.deftdevelopment.com

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have Firebug enabled? I've found that this has a profound impact on performance if the page uses JavaScript.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Guru rageh's Avatar
    Join Date
    Apr 2006
    Location
    London, Formerly Somalia
    Posts
    612
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Do you have Firebug enabled? I've found that this has a profound impact on performance if the page uses JavaScript.
    Yes I did have Firebug enabled at the time. Once I disabled it, everything was ok. It was indeed the Firebug that was causing the slow down.

    Thank you Autisticcuckoo. And thanks to all those who participated this.
    ------------------


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
  •