1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Disable JavaScript User Script

Related Resources

Enable Opera Userscripts

The correct way to use JavaScript is to add it to a web page that already works in order to make it easier to use. Not all sites use it that way though. In some cases the site ends up worse to use with the JavaScript in the web page than it was before they added the script.

You don't need to tolerate such poorly written JavaScripts on web sites you visit since you can always turn JavaScript off. Turning it off for all sites just to avoid the problems of a few sites isn't ideal though as then you miss out on the benefits on those sites that use it properly. Some browsers such as Opera make it really easy to turn JavaScript on and off by providing an easily accessibly option (you can easily copy the option from the menu to your status bar to give you a checkbox at the bottom of the browser to select and deselect as required). There is an extension for Firefox that provides equivalent functionality. Wouldn't it be better though if the scripts were disabled automatically without our even having to click a button?

This solution comes to us courtesy of the ability of modern browsers permitting us to install Javascripts into the browser itself that will run on those web pages that we select. The user Javascript that adds this link to our pages just need to be installed into the appropriate location on your computer to work with Opera (which has support for user Javascripts built in), Firefox (with the Greasemonkey extension that adds support for user Javascripts), or Internet Explorer 6+ with a plugin such as IE7Pro which adds equivalent functionality to that browser.

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". 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.

You only need to make one change to the script to get it to disable JavaScript on the sites you want it to automatically disable JavaScript on. Simply find the line near the top of the script that reads:

// @include       http://www.google.com/*

All that you need to do to get the script to work specifically with your site is to replace that entry with the address of the site you want it to block JavaScript for. You can then simply repeat that line as many times as required in order to disable JavaScript on whatever additional sites you want to disable it on automatically.

// @include       http://www.google.com/*
// @include http://www.yahoo.com/*

Note that this script works by actually stripping all of the JavaScript out of the web page after the page finishes loading so that no event triggered JavaScript can run. The script does not prevent any JavaScript running before the page finishes loading but since it is the interactive scripts that cause the problems removing the JavaScript once the page has loaded should be soon enough to fix the problem for most sites using JavaScript incorrectly.

See More About

©2017 About.com. All rights reserved.