Skip to content

Instantly share code, notes, and snippets.

@jasonferrier
Created May 3, 2023 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonferrier/96fcf6278720bb3bede70dd3d0764652 to your computer and use it in GitHub Desktop.
Save jasonferrier/96fcf6278720bb3bede70dd3d0764652 to your computer and use it in GitHub Desktop.
Show message in Browser Dev Tools Console when opened
/*
* Taken from Material UI documentation:
* https://github.com/mui/material-ui-docs/blob/af5e109990a26318c96dbff6f25759ba91f0e147/docs/pages/_app.js#L112
*
* The `%c` directive in the text output of the `log()` instance method applies CSS to the text AFTER the directive
* See documentation section "Styling console output" at the following link
* https://developer.mozilla.org/en-US/docs/Web/API/console#outputting_text_to_the_console
*/
if (typeof window !== 'undefined' && process.env.NODE_ENV === 'production') {
// eslint-disable-next-line no-console
console.log(
`%c
███╗ ███╗ ██╗ ██╗ ██████╗
████╗ ████║ ██║ ██║ ██╔═╝
██╔████╔██║ ██║ ██║ ██║
██║╚██╔╝██║ ██║ ██║ ██║
██║ ╚═╝ ██║ ╚██████╔╝ ██████╗
╚═╝ ╚═╝ ╚═════╝ ╚═════╝
Tip: you can access the documentation \`theme\` object directly in the console.
`,
'font-family:monospace;color:#1976d2;font-size:12px;',
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment