Javascript Noscript Content Blocker

Code snippet below.


This article shows how to manage website content from users and guests that have javascript disabled. Though there are several techniques, this is one of the easiest and simplest.

Why Users Disable Javascript?
People disable their browser javascript for several reasons: to save on bandwidth, improve browser speed, security fears against malevolent sites, not wanting to leave footprints (such as Google Analytics tracking), to block advertisements, accessibility issues such as being blind, and simply because they can. In the mindset of the user, each of these reasons are valid.

Javascript Noscript screenshot

Javascript Noscript

How Javascript Noscript Works
Noscript serves as a Browser messenger to notify the user that scripting has been disabled in their web browser when the script is being called for in the webpage. It's simply an alternative (or "alt") content in place of the missing javascript.


Place the following noscript code snippet anywhere in your web page between the <body> and </body> tags, but as far as cose to the opening BODY as possible:

<img src="your-image.jpg" alt="noscript" />
<style> a, .navigation, #search { display:none; }</style>

The above code in the style line is telling the browser to NOT display any "a href" links, hide the division class "navigation", and hide the division ID "search". With the above code you need to change the image and include any of YOUR page divisions you wish to not have displayed.

When To Use Javascript Noscript
We use noscript to block selective page content such as "a href" links. It's believed that most users with javascript disabled are those (1) avoiding advertisements, (2) who want to avoid Analytics tracking footprint data, and (3) who want to improve webpage load times.

It isn't important whether you agree or not with the manner or method we use noscript here. What is important is its' design and effectiveness.

It's arguably agreed that using an image rather than text for your noscript message is far more safer in terms of SEO and page rank.