When outputting messages into the console, the source is also displayed (in Chrome Developer Tools it's on the right):
console.log("Foo"); //Source Foo test.js:1 //Output
However, on some sites, messages are displayed without the source being displayed, such as on Facebook:
Having a look on the Chrome Console API Reference there are examples across a ton of different outputs but all of them have the source displayed.
How can I hide the source (.js
page and line number) of console outputs?
Edit: Just for clarification, this is not a duplicate of How does Facebook disable the browser's integrated Developer Tools? as that question answers how the console disables standard user input (and its answers explain how it works). I am specifically asking about the aesthetic of not displaying the source file and line.
In Chrome's Console tab you have a Filter box, type there the name of the file you want to filer out, with a minus sign "-" before the file name. You can filter multiply files, using space as a delimiter. Or instead of typing, just right click on a log message, and select Hide message from <file_name> .
They are using setTimeout
to detach from the source:
setTimeout(console.log.bind(console, '\n%c' + s[0], s[1]));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With