Check out my overview of Chrome DevTools if you’re new to them
In the Elements panel, you can drag and drop any HTML element and change its position across the page
Select a node in the Elements panel, and type
$0 in the console to reference it.
If you’re using jQuery, you can enter
$($0) to access the jQuery API on this element.
$_ to reference the return value of the previous operation executed in the Console
In the Elements panel there are two super useful buttons.
The first lets you add a new CSS property with any selector you want, but pre-filling the currently selected element:
The second one lets you trigger a state for the selected element, so you can see the styles applied when it’s active, hovered, or on focus.
Click the name of the CSS file that you edited. The inspector opens it into the Sources pane, and from there you can save it with the live edits you applied.
This trick does not work for new selectors added using +, or into the
element.style properties, but only for modified, existing ones.
Select an element and press
ctrl-shift-p in Windows) to open the Command Menu, and select Capture node screenshot
ctrl-f in Windows) opens the search box in the Elements panel.
You can type any string in there to match the source code, or you can also use CSS selectors to have Chrome generate an image for you:
To write commands that span over multiple lines in the Console, press
Once you’re ready, press enter at the end of the script to execute it:
You can clear the console using the Clear button on the top-left of the console, or by pressing
In the Sources panel:
ctrl-oin Windows), shows all the files loaded by your page.
ctrl-shift-oin Windows) shows the symbols (properties, functions, classes) in the current file.
ctrl-ggoes to a specific line.
Instead of writing again and again a variable name or an expression you are going to check a lot during a debug session, add it to the Watch Expression list.
From the debugger open the XHR/Fetch Breakpoints panel.
You can set it to break any time an XHR/Fetch call is sent, or just on specific ones:
Right-click an element and enable Break on Subtree Modifications. Whenever a script traverses that element’s children and modifies them, the debugger stops automatically to let you inspect what’s happening.
I wrote an ebook about Modern Web Development including React, Redux, Progressive Web Apps, ES6, ES7, ES8, Webpack, GraphQL, Babel, Service Workers, Fetch, Push Notifications and lots of other things you need to know! Get it now! 😀
Originally published at flaviocopes.com.