17

I am looking for a way to prevent loading a specific JavaScript file on a website for any website of choice, with Firefox.

For example: Say I don't want to load jQuery (when loading the page, not afterwards 'disabling' it). I then want to be able to set that

http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js

should not be loaded. The browser should complete ignore this to debug other JavaScript on the website. I don't have access to the domain directly, so that is why I am trying to do this via the browser.

So for clarity: :) I don't want to disable scripts from a certain domain, but want to be able to disable certain scripts. It can be that 10 scripts are on 1 domain, so killing all 10 of them is not what I want; in that case I want to prevent loading only one.

Is there a way to do so?

1

2 Answers 2

18

Several options:

  1. Use the Addon "Adblock Plus". It will probably still accesses the js but does not execute it.

  2. Use the Addon "Greasemonkey", which - when cofigured right - does not even touch the js-url. But its generally harder to configure right. ;)

  3. Have a look at Firefox's buildin security policies: http://kb.mozillazine.org/Security_Policies Here you can block javascript on an url or even function-level

Sign up to request clarification or add additional context in comments.

2 Comments

Indeed, AdBlock Plus is a very good tool for that kind of stuff :) The script won't even get downloaded. You can also choose to block this script only on pages in particular domain etc.
The Firefox Security policies for Javascript are discontinued since Firefox 29: support.mozilla.org/en-US/questions/1000843
2

Go to your hosts file C:\Windows\System32\drivers\etc (Windows) or /etc/hosts (Linux).

Add: 127.0.0.1 ajax.googleapis.com (separated by a tab)

And reopen your browser This way the jQuery file will fail to load.

3 Comments

Thanks for your answer, however this is not working if there are more JavaScripts on the same domain and you want to disable one of them. I have updated my question for clarification.
@NiklasRingdahl It doesn't even answer the question.
This worked for me! I just wanted to block a whole domain. For those wanting easy host file access on a Mac, I recommend hosts for Mac.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.