is JavaScript or Ajax codes affect the website performance?

Discussion in 'HTML & Website Design' started by jasonmark, Jan 24, 2011.

  1. #1
    My website has a lot of ads and i also use the Openx script. all these are run on JavaScript platform as well. i have 4-5 ads per page. will this increase my website loading time?
     
    jasonmark, Jan 24, 2011 IP
  2. RadioBounce

    RadioBounce Banned

    Messages:
    4,171
    Likes Received:
    16
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Well, I guess you could put the javascript at the bottom of the page so it loads last to avoid slowing down the loading of the main content on your page. One method I use to make my website(s) load faster.
     
    RadioBounce, Jan 24, 2011 IP
  3. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #3
    More than likely, yes.

    If the javascript is being served externally, like most ad networks are, then there are Http requests being made to contact the server and send the script, plus whatever time that server needs to dig up the data to send to you. The more external scripts you have, the longer the page load.

    Sometimes you will get one of those scripts (ahem .... Facebook ... cough ) that leave a big gaping hole in your sidebar and the spinning wheel in your browser. Then bam. The sucker appears, and depending on the styling, may make the page jump unexpectedly.

    There are ways of making the site "appear to load faster" by shoving as many of the scripts as possible into the end of the Html near the closing Body tag. This way, those scripts do not get a chance to run until most of the regular part of the page (Html, CSS, images) have loaded. Most tracking scripts get loaded down there, and should be loaded down there (forget what they tell you about loading them in the Head for more accurate tracking ... screw that, if you miss a couple of stats, so be it.)
     
    Dodger, Jan 24, 2011 IP
  4. RadioBounce

    RadioBounce Banned

    Messages:
    4,171
    Likes Received:
    16
    Best Answers:
    1
    Trophy Points:
    0
    #4
    True dat, I'd rather have my websites load faster than be able to track those people who don't even load the full website before they leave LOL.
     
    RadioBounce, Jan 24, 2011 IP
  5. danramosd

    danramosd Active Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    83
    #5
    Yes it can affect your load time. A good way to determine if/how much it affects your site download and install firebug for firefox. Go to the page and open firebug and click on the Net tab. It will break down all of the HTTP requests, the size, and how long it takes to load and run the script.
     
    danramosd, Jan 24, 2011 IP
  6. calvin4u

    calvin4u Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    My website loads pretty much the same speed as the other similar websites. But when I use the Pingdom.com's webtool to check the load test, I found out my website was categorized as Slow if compared to the others. Is it because I use plenty of javascript/Ajax (ads)
     
    calvin4u, Jan 27, 2011 IP
  7. AtSeaDesign

    AtSeaDesign Active Member

    Messages:
    172
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    93
    #7
    Because scripts I believe are not loaded in parallel it's best to do one of the following.

    1. Use a CDN for scripts. If you can't afford one at least use Google's or MS' code base. Most users coming to your site will more than likely have the script already cached from one of them. If you run it off your server, you have the issue above with load times and unless they are regular users to your site, it won't be cached.

    2. Compress and combine your scripts into 1 file with versioning. You can do this via your htaccess file or php. This saves from the parallel issues and multiple HTTP requests.

    3. Try to load what you can at the end of your page. It's trial and error as some things on the page may not work correctly with scripts at the bottom.
     
    AtSeaDesign, Jan 27, 2011 IP