What is the best way to detect a users download speed?

Discussion in 'JavaScript' started by Imozeb, May 14, 2010.

  1. #1
    I have a few images and objects which I only want my site to show if the user has a fast download speed (kb/s). How would I check a user's download speed without effecting my sites performance using javascript?

    Thank you.
     
    Imozeb, May 14, 2010 IP
  2. amrox

    amrox Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Interesting question, surprised that it has received no response

    You could probably use some PHP/Perl in your page header, to download some random temp file, and to time that process, once its complete, it can then calculate the kb/s with the file size. This can then trigger the loading of imageA or the smaller imageB or even no image depending on results. The tricky part is, the smaller the file, the less reliable the result will be, the larger the file, the longer your webpage will take to load...

    Another method would be to start loading the image (using a Perl/PHP script), if it takes longer than x seconds/milliseconds, then abort and start loading the smaller image? If you use a function, then you can apply this to all your images.

    Without looking at speeds, what you could also do is change the order that objects load on your page so that the large objects load last. If someone has a slow connection, then at least the important stuff has already loaded, if they don't get to see the large objects, then nothing is lost and If they chose to wait then they can.

    Would need to know more about your hosting platform and site structure to give any specific recommendations.

    Alternatively you could always have two links for the page, slow connection & fast connection - not ideal but it will address your issue.
     
    Last edited: Jun 19, 2010
    amrox, Jun 19, 2010 IP