Run JS code in debug mode only

Is it possible to execute part of the js file only when opening developer tools?

I need something like

#if DEBUG
executeMethodOnlyInDebugger();
#endif

but for javascript.

+4
source share
4 answers

No, no conditional compilation originally in javascript.

+3
source

Not really. But you can use devtools-detect . See the following answer: enter the link here

+2
source
0

, Chrome Firefox. .

IE undefined, . IE :

if(console){
  //dev tools is open
} else{
  //dev tools not open
}

: , Chrome

0

Source: https://habr.com/ru/post/1612271/


All Articles