In this Modern web world a web page doesn’t exist without JavaScript code. Agree?

 To me, detect if JavaScript is enabled in the browser or not is a mandatory check a developer needs to perform before start writing tons of lines of JavaScript code.

Come on in.. let’s quickly learn how this check can be done. 

Ok first thing first, let’s create a simple HTML page and add few lines of code to deal with JavaScript detection.

To detect if JavaScript is enabled, let’s run document.write("Awesome, JavaScript is enabled!") inside <script> tag.

On the other hand, we are gonna use <noscript> tag to check if JavaScript is disabled. Just note that browser will render <noscript> tag only when JavaScript is disabled.

<!DOCTYPE html>
    <title>Detect JavaScript</title>
      	document.write("Awesome, JavaScript is enabled.");
    	<noscript>JavaScript is disabled, please turn on!</noscript>


JavaScript enabled:

JavaScript Enabled Demo

JavaScript disabled:

JavaScript Enabled Demo

All right, just few lines code does the magic! Let me know if you have any questions or something to share with me about this post in the comments section down below. 

Happy learning!

Join the Newsletter

Subscribe to get our latest content by email.
    We won't send you spam. Unsubscribe at any time.