Disable JavaScript

Modern browsers provide an option in the browser settings itself that allow you to decide whether JavaScript in a web page is or isn't allowed to run. The following instructions will allow you to disable JavaScript completely in your browser (and also to re-enable it again if you change your mind in the future.

The problem with disabling JavaScript completely is that you probably do want JavaScript to be able to run on at least some web pages that you visit regularly while wanting to have it disabled for other web pages. Some browsers provide additional options within the browser that allow you to enable or disable JavaScript on a site by site basis. Where the browser doesn't provide this as built in functionality you can usually find a plugin or extension for the browser that will add such functionality. Some of these are even more flexible allowing you to enable and disable JavaScript on a page by page basis.

Even this may not provide all of the flexibility that you want with regard to what JavaScript to allow and what to disable. In some instances we may want only some of the JavaScript within a web page to run while preventing other scripts in the same page from running. We can handle some of these situations as well using JavaScript itself to disable the scripts after some of them have already run.

The Javascripts in any web page can be divided up into two groups. The first of these are the scripts that run as the web page is loading or immediately after it loads. The second group cososts of code that runs in response to events occurring as you interact with the web page. Suppose that we have a web page where we want the code in the first of these groups to run but we want to prevent the scripts associated with any event processing to be disabled. The easiest way to achieve this is to attach a script into the bookmarks/favorites menu or toolbar of our browser that we can run at any time to disable any further JavaScript running on the current web page.

To install a "disable JavaScript" bookmarklet into your browser simply right click on the following link and select the add to favorites or add to bookmarks option from the context menu.

Disable Javascript on this page

We can go one step further by automating this process by installing a user script into the browser itself and using @include or @exclude statements to determine which web pages it will run on.

The killjs.user.js script just needs to be installed into your particular browser. For Firefox/Greasemonkey simply right click the link and select "Install User Script". In Chrome you need to first right click and select to download the file then Click the wrench icon on the browser toolbar and select Tools then Extensions and then drag the file you saved onto the Extensions page proceed, then click Install. With Opera the easiest way is to go into the link and select "Save As" from the "File"menu to save the script into your user script folder. How you should copy the script for use with Internet Explorer depends on which plugin you use to add userscript support.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow