ChatGPT解决这个技术问题 Extra ChatGPT

How to disable JavaScript in Chrome Developer Tools?

I am trying to debug the features of a website when users disable their JavaScript. I was wondering how do you disable JavaScript for a page from the Google Chrome DevTools?

The command menu, which has been around since about April 2016, is probably faster than the older workflows that relied on going into DevTools settings: stackoverflow.com/a/40727332/1669860
I am adding this as a comment because it does not answer the OP question, but it answers a related question that I was looking for (I found this, but not an answer to my question). If you want to turn off only a specific script, for example a slide show, because it is impeding efforts of adjusting CSS styles in Dev tools, do the following: Go Sources tab. Navigate file tree to find the script (usually you want to choose the minimized version). Click the || pause button. Now you can go back to the Elements tab to inspect/edit CSS without HTML (& scroll location) constantly changing.

S
SherylHohman

Click the gear icon in the corner of the Developer Tools, click Settings, then under Debugger, check Disable Javascript, as shown in the following video:

https://i.stack.imgur.com/9S7eq.gif


If still not working, consider Ctrl+Shift+n, Open new Chrome window in incognito mode.
@PaintyJoy, thanks for that tip. For some reason my "Disable Javascript" is being buggy when I refresh... "Incognito Mode" -> F12 > Settings > "Disable Javascript" -> Refresh works! Would love to know WHY it's not working in regular mode. I haven't found any tickets for this issue. Seems to only happen to certain users.
@MattParkins Chrome Developer Tool seem to break every now and then ("complex" code I guess ^^). So use Alex's answer isntead stackoverflow.com/a/13405449/759452
Can you please add a screenshot that shows the location of the "gear" icon in the lower-right corner of the Developer Tools? For example, here is a screenshot of the Developer Tools that shows there is no "gear" icon.
You will now find the "Disable JavaScript" option on the right side in de Preferences menu. Headline is: "Debugger"
S
Scott Decker

Update August 2020

Developer Tools (F12) Click the Gear icon

https://i.stack.imgur.com/tb2Wp.png

Should open the Preference tab Disable Javascript option is on the far right

https://i.stack.imgur.com/913Ab.png

Original answer

Developer Tools (F12) Three vertical dots in upper right Settings Under the "Preferences" tab on the left

https://i.stack.imgur.com/hvOvj.jpg

There will be a "Debugger" section with the option (probably on far right)

https://i.stack.imgur.com/L8isH.jpg


Correct, they made it heck lots harder to find, no idea why.
Maybe it's less important now so many web apps require JavaScript? It's so frustrating because I have to keep testing graceful degradation so I need to continually switch back and forth.
K
Kayce Basques

Official documentation: Disable JavaScript With Chrome DevTools

There's now a command menu built into DevTools that makes it easier to disable JavaScript. This has been around as of April 2016 or so.

Open DevTools. Press Command+Shift+P (Mac) or Control+Shift+P (Windows, Linux) to open the Command Menu. Make sure that your cursor's focus is on the DevTools window, not your browser viewport. Type Disable JavaScript (or some version of that... it's a fuzzy search) and then press Enter.

Use the Enable JavaScript command when you want to turn it back on.

https://i.stack.imgur.com/AMGrD.png


have devtools active before trying this.
B
Babadzhanov

chrome://settings/content Javascript/Manage Exceptions


m
mlb

This extension makes it faster (I am the author) : Quick Javascript Switcher

It is open source: https://github.com/maximelebreton/quick-javascript-switcher


Great tip, works superduperly — quick and simple and reloads the page too! Instant on and offness
Bad thing is that it reloads the page, while I need it not to do so.
@polkovnikov.ph it appears to have been addressed, there is now a Auto-Refresh option. Maxime, it would be good to say in the answer that you are the author. The only big missing thing is a shortcut or documentation for it: github.com/maximelebreton/quick-javascript-switcher/issues/32
Thanks @CiroSantilli新疆棉花TRUMPBANBAD, this is fixed.
j
jaredwilli

You can also run Chrome with JavaScript disabled by default by using the flag:

-disable-javascript

You would use this for example by running Chrome like this:

C:\Documents and Settings\%username%\Local Settings\Application Data\Google\Chrome" -disable-javascript

-disable-javascript doesn't work with google-chrome-stable-51.0.2704.106-1.x86_64.
Try --blink-settings=scriptEnabled=false instead
r
remborg

The quickest way is problably this one:

F12 to open the dev console

ctrl + shift + p to open the command tool (windows)

Type 'disable javascript' and hit enter


D
DigitalDesignDj

On OSX, I had to click the triple vertical dots, and uncheck a box in the settings section. Which can also be opened with f1


b
bishop

Using only the keyboard at least for Windows 10:

F12, shows Developer Tools

F1, shows Settings

tab, moves to the "Disable Javascript" check box

space, toggles the option

esc, hides Settings


N
Niels Bom

On Mac OS X:

Preferences

Show advanced settings

Press the "content settings" button

Scroll to the "JavaScript" section

Check the checkbox in front of "Do not allow any site to run JavaScript"

The Chrome Quick JavaScript Switcher extension is a lot easier though :-)


C
Community

Go to options (Windows: three vertical dots in the top right) -> Settings, or hit F1.

In the General section you find "disable JavaScript"

The gear icon is no longer part of developer tools. Since Chome 30.0 it is not even possible to bring it back (In Google Chrome Developer Tools, the toolbar icons disappeared. What gives?)


A
Anu Shibin Joseph Raj

To temporarily block JavaScript on a domain :

Click on the Button left to the address on the address bar (which says View site information) In the drop-down next to JavaScript, select Always block on this site Reload Page


S
Sarang

Click the ⋮ menu in the corner of the Developer Tools, click Settings

Click on Advanced at the bottom

Click on Content Settings

Click on JavaScript

Switch off


m
marcdahan

The fast way:

1) just click on CTRL + SHIFT + P

2) fill the field by the 3 letters dis and will appear this box and select the item Disable Javascript

https://i.stack.imgur.com/vGr2r.png

that's all folks!


B
Bharata

Full and fast instructions for Chrome browsers (Opera incl.)

The first way

If Developer Tools aren't open then press F12 key on keyboard to show the Developer Tools. In Opera browser you have to use key combination Ctrl + Shift + i on keyboard to open it. To show the settings just press F1 key on keyboard. The Developer Tools window must be focused when you are doing it. Or if you want to open the settings with the mouse then you have to click on ⋮ button in the top right corner of the Developer Tools, then click Settings in the menu.

Then you have to scroll down the settings window to bottom and then you will see the checkbox for disabling JavaScript like follows:

https://i.stack.imgur.com/BKEgJ.png

Just click on this checkbox and push esc key on keyboard for hide the settings. If you want to enable it then you have to do the same way again.

The second way

If Developer Tools aren't open then open it like in the first way is described. Press the key combination Ctrl + Shift + P (for Windows or Linux) or Cmd (⌘) + Shift + P (for Mac) to open the Command Menu. Be sure that the focus is on the DevTools window. Type there "Disable JavaScript" and then press Enter or click it with the mouse. If you want to turn back the enanled JS then open the Command Menu again and type there "Enable JavaScript" and then press Enter or click it with the mouse. You could also write just only "JavaScript" or "Java" there and then choose it with the mouse.

https://i.stack.imgur.com/xEmlF.png

If all this does not work

For some reason it is possible that it does not work. I this case open a new empty site in "Incognito Mode" and do all this there.

The quickest way

In Chrome Web Store or on Opera Addon site you can find and install extensions which do it per one click. Just search "Javascript Switcher":

For Chrome browser

For Opera browser


D
Dan D.

Press F8 for temporarily freezing / unfreezing JS (with DevTools open).

This is very useful for debugging UI issues on elements that may lose focus if you click or press anything outside of that element. (Chrome 71.0.3578.98, Ubuntu 18.10)


a
aletede91

Paste it: chrome://settings/content

Go to "Javascript" section and disable it.


Could you provide more detail? The user has to go down to the JavaScript section and choose "Block".
C
Chirag Dave
Chrome://chrome/settings/Privacy/Content settings/JavaScript

and there you can PASTE your website's URL in Manage exceptions.. and change the JavaScript priority from ALLOW to BLOCK.


S
Sheo Sagar

This is the latest setting for the windows

Settings > Advanced > Privacy and security > Site Settings > Javascript > Blocked then get switch on and off

d
defend orca

good question, i try so many way, but it is curry and boring, until i find shortcut.

alt + cmd + i, this open dev tools, unless you use pocket, that need set other shortcut. shift + cmd + p, then input: javascript

only two shortcut, but i think safari is more convenient for that.


P
PauAI

There's a settings in chrome

open the menu from chrome, click settings > type in "javascript" in the search bar > click site settings > click javascript.

from here you can toggle javascript specifically to a site using their url. or just click the big button to allow/block it to all sites.

https://i.stack.imgur.com/5V7ql.png