Jecelyn will share some tips and tricks to help you debug your web app effectively with Chrome DevTools.
This talk has been presented at JSNation Live 2021, check out the latest edition of this JavaScript Conference.
Jecelyn will share some tips and tricks to help you debug your web app effectively with Chrome DevTools.
This talk has been presented at JSNation Live 2021, check out the latest edition of this JavaScript Conference.
To quickly access specific panels or features in Chrome DevTools, use the Run Command feature by pressing Command + Shift + P (or Ctrl + Shift + P on Windows/Linux). Type the name of the feature, such as 'media' to open the Media panel or 'capture' for screenshot options.
Yes, you can customize keyboard shortcuts in Chrome DevTools. Go to Settings, then Shortcuts, where you can modify existing shortcuts or add new ones to suit your workflow.
To keep a dropdown menu open for inspection, use the Run Command feature by typing 'focus' and selecting the 'Emulate a focus page option'. This emulates the focus effect and keeps the dropdown visible.
The Memory Inspector in Chrome DevTools allows you to inspect JavaScript array buffers and WebAssembly (WASM) memory. Set a breakpoint, refresh the page, and click the new icon next to the buffer value to open the Memory Inspector. You can navigate and inspect memory changes in real time.
In the Network panel of Chrome DevTools, hold the Shift key and hover over a network request. DevTools will highlight initiators in green and dependencies in red, helping you understand the relationships between requests.
To change the user agent in Chrome DevTools, go to the Network conditions tab, click on the network conditions icon, and select a user agent from the dropdown menu, such as Google Bot for SEO testing. You can also set a custom user agent if needed.
Live expressions in Chrome DevTools allow you to monitor JavaScript expressions in real-time. Type an expression in the console and pin it. The expression will update dynamically as changes occur in the page, which is useful for tracking values without repeatedly typing the command.
In Chrome DevTools, go to the Sources panel, open the Snippets pane, and create a new snippet. Save frequently used code as snippets and execute them directly from the command menu using Command + P and typing '!' followed by the snippet name.
The local overrides feature in Chrome DevTools allows you to make and save changes to a webpage without affecting the live site. This is useful for testing and debugging local versions of a webpage before deploying changes.
To debug DevTools with another instance, ensure your DevTools window is undocked and then press Command + Option + C (or Ctrl + Shift + C on Windows/Linux). This opens another DevTools instance, allowing you to inspect and debug the original DevTools like any other web application.
I'm Jasleen Yin, the developer advocate for Chrome DevTools at Google. Here are some tips to better utilize DevTools for debugging: use the run command to quickly access panels and features, customize your own keyboard shortcuts, and emulate the focus effect to debug dropdowns. Stay tuned for the next feature.
Hi all, I'm Jasleen Yin. I work at Google. I'm the developer advocate for Chrome DevTools. As a web developer, I use Chrome DevTools every day to debug my web applications.
Let me share with you some tips that might help you better utilize DevTools for debugging. First tip is about getting to the panel or feature you need quicker with run command. For example, if I want to debug my video, I can go to run command, type media and click enter to open the media panel. Or if I want to capture a page screenshot, I can run command with the command shift P keyboard shortcut and type capture. Here you can see a list of screenshot options. Scroll through the list. You will be surprised that there are many commands that you can run. Run command helps save my brain memory because sometimes I just don't remember which panel to open to emulate the CSS stuff theme, for example.
Next there are a bunch of keyboard shortcuts in DevTools, but we as humans have limited memory. Instead of memorizing the shortcuts DevTools predefined, you can now customize your own shortcuts. Go to settings, shortcuts. I can customize the run command shortcut. I can either replace the current command shift P shortcut or add another shortcut, say option C to the same command. If you are using Visual Studio Code as code editor, you can map the shortcuts to that as well.
Next, there are times I want to debug my search dropdown. However, when I right click inspect on the search box, the dropdown is gone. This is annoying. I mean, I just want to debug the dropdown. Please help. Okay, cool down. Let's pull out the run command and type focus. Select the emulate a focus page option. Problem solved. The reason being is the dropdown is triggered when the user focuses on the input. So use DevTools to emulate the focus effect and you are good to go.
Next, a new feature.
For memory inspection, use the memory inspector to inspect array buffers and WASM memory. In the network panel, find initiators and dependencies of network requests, change the user agent, and use filters for more control. In the console, use live expressions to track values in real time and take advantage of console utilities.
For folks who deal with memory a lot, you can now use the memory inspector to inspect the JavaScript array buffer and WASM memory. For example, I have an array buffer here. Let's set a breakpoint and refresh the page. Notice the new icon next to the buffer value. Click on it to reveal the memory inspector. Then you can navigate around and resume the script executions to inspect the memory changes in real time. Learn more about the memory inspector with this documentation.
Next, let's look at the network panel. There are times we want to find out the initiators or dependencies of a particular network request. Hold the shift key and hover the mouse over to the request in the request table. DevTools colors initiators green and dependencies in red. Next, you can change the user agent in the network conditions tab. For example, you would like to make sure your page works for search engine optimization because some servers or CDN configurations might block crawlers by default. You can debug such behavior by clicking on the network conditions icon, choose Google Bot from the dropdown, and refresh the page to see if any errors occur. You can also set a custom user agent if none is found on the list. Next, some tips on the network filter. You can filter the list by the size. Here, I use the larger than keyword to find out requests that are larger than 15 KB. What if I want to find all the requests smaller than 15 KB? I can use the negative sign to negate this filter result. For example, you can exclude all requests with status 200 with the filter negative status code 200.
Next, let's move on to the console. If you find yourself typing the same JavaScript expression again and again during debugging, consider using the live expressions. This way, you type an expression once and then pin it on the top of your console. The value of the expressions updates in near real time. I would like to keep track of the dotted images in this page. Click on the create live expressions icon and type document.querySelectorOrImg.length. Right click and duplicate the image element now. See, the number is updated automatically. Nice right? There are also a few handy console utilities that can save your typing time. Right now, we use document.querySelectorOr to get the dotted images of the page.
We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career
Comments