Solved

Redirect users according to their bandwidth using Javascript

Posted on 2007-04-03
6
312 Views
Last Modified: 2013-11-25
Hi

Depending on the users bandwith I have to redirect the users to different asp pages
Is there a way to find if they are using high / low bandwith and redirect accordingly in Javascript ?

Thanks

0
Comment
Question by:ranirajesh
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:ethoths
ID: 18841892
There is no precise way to do it but you could try this....

1) Create a page with some javascript i the head that gets the current time.
2) As the last line in the body get the time again. The difference between the two will be a measure of how long the page took to load (and hence the bandwith).
3) Depending on the time determined in 2 redirect to the appropriate page.

This will require a little calibration to get right and the page that you use to do this will have to have some amount of content to make it take some time to load but it should work.

(Another way would be to do the same thing in AJAX. Since this is asynchronous your users should not notice any delay.
0
 
LVL 11

Expert Comment

by:flipz
ID: 18842307
@ethoths - I don't believe your theory will work. Since Javascript is only processed once the code is already in the browser - calculating the time between to 'head' and 'footer' times is more a measure on how fast the client machine runs the script.

AJAX is a closer measure but again there are issues with server traffic etc. that would affect the response time and not sufficiently give you an accurate time. You could try it by taking the current time in JavaScript - place an AJAX call to an .asp page, take the time when the response is recieved - subtract the difference of the two times and subtract the processing time of the .ASP page and you will get a (somewhat inaccurate) measure of bandwith.

0
 
LVL 11

Expert Comment

by:ethoths
ID: 18842419
Yes you are right, the code will run as soon as it is in the browser. The code in the head will run just after the page starts loading and the footer code when it is loaded. It's not really measuring the time it takes the page to load, rather it's taking a measure of the time elapsed between the head code loading and the footer code loading. This is somewhat related to the time that the page takes to download.

My understanding was that the requirement was to determine whether the user has a low bandwidth connection (56k Modem) or a high bandwidth 2Mb ADSL. If this is the case then there is a factor of 40 between the them. In this case accuracy is not really required. If the page loads in less than 1 second then it's ADSL, if it takes more than say 20 then it's not. A bit of imperical calibration will yeild reliable results.

I agree that the AJAX approach will yeild even better results but it might be a little overkill for a simple "go/no-go gauge".
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 11

Accepted Solution

by:
flipz earned 250 total points
ID: 18842459
ethoths - as I understand it - the actual JS code does not actually run until the page is fully loaded. Even if you put a timestamp in the head of the page - the JS call to get that time will not fire until the entire HTML is loaded into the browser. This means that any JS code running would have nothing to do with bandwith.

I agree that there is a considerable difference between dial-up and ADSL so some innacuracies are acceptable but what if a user on ADSL runs the page but the server is too busy to respond and takes 20 seconds to run? Then the client code would assume that the connection is dial-up.

In any case - ranirajesh - you're probably just better off the let the user choose their own connection speed.
0
 
LVL 11

Assisted Solution

by:ethoths
ethoths earned 250 total points
ID: 18842622
Yes flipz: you are correct about the running of the JS and my first suggestion would not run. My suggestion about AJAX looks like the best way.

Incidentally, the fact that a slow server or connection could result in tha inaccurate selection of page is a good thing. It does not really matter why the page is slow to load. If it is slow for any reason then the leaner version should be used.

Letting users choose has several disadvantages...

1) Some users won't know.
2) Some will choose the wrong answer
3) Some will be scared off by such a technical question.
4) It cannot dynamically auto configure
5) If the choice is perisited as a preference and the user then upgrades, they will not be getting the best experience.
0
 

Author Comment

by:ranirajesh
ID: 19353947
Thanks to both of you ... My mistake for not responding earlier ...  for the time being I have left the choice to the user , but in future I would definitely like to try out using AJAX
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now