How to detect if JavaScript is disabled?

Ask a question

Does anyone know of some simple ways to detect if JavaScript is disabled? My intention is to give a warning that the site is not able to function properly without the browser having JS enabled.
Eventually I would want to redirect them to content that is able to work in the absence of JS, but I need this detection as a placeholder to start.

offer bounty
add comment

3 Answers


As I understood you’re trying to decide whether or not to deliver JavaScript-enhanced content. The best implementations degrade cleanly, so that the site still operates without JavaScript. I also assume that you mean server-side detection, rather than using the < noscript > element for an unexplained reason.
There is not a good way to perform server-side JavaScript detection. As an alternative it is possible to set a cookie using JavaScript, and then test for that cookie using server-side scripting upon subsequent page views. However this would not be suitable for deciding what content to deliver as it would not be able to distinguish visitors without the cookie from new visitors or visitors who are blocking cookies.

add comment

This is what worked for me: it redirects a visitor if javascript is disabled```html


add comment

There is a special tag noscript for this purpolse

<noscript>Your browser does not support JavaScript!</noscript>
add comment

Your Answer