I have the understanding that disabling JavaScript on a website prevents any scripts from running — I will get the site contents, raw and unevaluated.

But when I disable JavaScript (on Chrome) on twitter.com, I am redirected to mobile.twitter.com. I can't pause the browser on load using debugger or the like, since JavaScript is disabled. And the redirect happens too fast anyways. (This is doubly annoying since I can't go back to twitter.com to un-disable JavaScript!)

So, how is Twitter

  1. detecting that I have JavaScript disabled and
  2. performing a redirect without JavaScript?

And, how do I stop this from happening?

edit: Twitter now has a comfirmation screen before redirecting, but in the past it automatically did a redirect without any prompt. I'd like to know how they did that.


Not all redirects are based on JavaScript or require active involvement of your browser.

One way this can be done is via a "meta-refresh" page that is set to immediately refresh on a different page, in your case the mobile site.

So how does Twitter know to give you this page? Because your web browser told it to. On every request for a document your browser will send a useragent string telling the website what browser, OS and version details.

The useragent string is intended to make it possible for a web server to detect and send a version of a webpage that is specifically supported by the requesting device. In the past this was done to make sites that were tailored to the somewhat sporadic support for functionality across browsers.

What it means though is that they can easily detect and redirect mobile users to a more friendly interface.

To get around this most browsers can be set to "request desktop site" which changes their useragent string to pretend your device is a desktop browser.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.