Prototype & Scriptculuos makes my site slow load

Discussion in 'JavaScript' started by miexl, Jul 27, 2009.

  1. #1
    In my <head> section i do have this line of code:

    <script type="text/javascript" src="/js/prototype.js"></script>
    <script type="text/javascript" src="/js/scriptaculous.js"></script>
    
    Code (markup):
    Its pretty obvious that I need ajax in my site but when I removed that code my site loads faster so I end up choosing not to use it.

    I really like to use ajax but how to use it without affecting my site load time?
     
    miexl, Jul 27, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    make sure you have a content type handler (via httpd.conf or .htaccess) that deflates .js files - this enables gzip compression and reduces size to client, hence reducing the time it takes to download. however, sometimes the reverse effect is noticed - when the server is lagged / cpus are under heavy load, it may add to the time it takes to prep the data.

    anyway - there are a few other issues known to cause this. for example, having inline js blocks can cause a huge delay, here's an extract from google labs' keynote on web performance at AJAX Experience this summer:

    in other words, you can't really tell why something is performing slowly unless you look at the whole picture and profile it.

    it could also be the domready / onload being messed up / firing late. to profile speed - install firebug, then YSlow for firebug and check components. you can then also profile the javascript itself to see if a particular function is not being too slow.

    good luck :)
     
    dimitar christoff, Jul 27, 2009 IP