30
Chrome Devtools
If you're a web developer, you're probably used to using the Chrome DevTools. I'm certainly one of the many developers who uses Chrome, but despite using it for years, I've always had a nagging feeling at the back of my mind that I wasn't using it efficiently. I therefore decided to do a bit of a deep dive into the Chrome DevTools, to try to figure out what the tabs beyond Elements, Console and Network are for, and what other hidden gems lay beneath.
Here are my notes. I've written it as more of a cheat sheet, rather than a well-formed reference document, to remind myself of what tab does what in the future.
document.designMode = "on"
. This allows you to add elements directly in your browser.settings
, and tick Show user agent shadow dom
within the Elements
section. This will allow you, for instance, to break down HTML 5 video
into its sub-elements.* { border: 1px solid red; }
to set a red border around all page elements, allowing you to identify off page elements.manifest.json
is loading properly.- Check what the print media query looks like if you've set it.
- Check your various layers of elements by adding borders around them.
- Highlight advertising frames.
- Display paint refreshes.
- Test what dark mode looks like.
debugger;
in your javascript file. Upon running this the Sources tab will automatically open.- You can also see the different JS scopes - local, global and closure (e.g. React's App.js)
debugger
basically sets breakpoints in our code. Either:
- Just set one
debugger
then use thestep over functions
button to go through your code line by line; or - Litter your code with breakpoints and press the
play
button. This will just pause on exceptions and debugger break points.
show memory timeline
and filter for just the JS memory heap.- The
heap snapshot
option shows a snapshot over the time period it takes your site to load. - The
allocation instrumentation on timeline
option gives you a visual graph as time progresses.
CMD + Shift + P
. I use it to switch on/off dark mode for instance.Any more tips? Talk to me on Twitter or Instagram @bionicjulia