Updated Chrome Debugging Tools Worth Mentioning

As a web developer, I absolutely could not live without great in-browser developer tools. I use them every day, and they can certainly make your life much easier. Typically my browser of choice is Chrome, so I thought I would take some time to introduce a few new features in the latest release that are really, really cool.

So, Google Chrome's latest version (59) has quite a few new features that are worth mentioning and that I'll briefly review within this post.

  • Explicit Request Blocking
  • CSS and Javascript Code Coverage
  • Full Page Screenshots
  • Async Await Step Over

Explicit Request Blocking

Troubleshooting unknown or unexpected scenarios can be tough to do sometimes. Simulating if your CDN is down, or if a given resource simply fails to load can be done, but this latest Chrome feature makes it much, much easier.

Chrome now allows you to simply block a request from resolving, allowing your specific fallback logic to kick into gear and see how your site reacts. This feature can be set up two ways by either explicitly defining some patterns to determine which requests to block using Menu > More Tools > Request Blocking,

Web Development

Or by simply right-clicking a particular request that you want to disallow in the Network menu and choosing the 'Block Request' option,

RequestBlocking

CSS and Javascript Code Coverage

As developers, we should always be striving to be better and in the realm of web applications, this typically means getting the client what they need as fast (and efficiently) as we can.

Generally you can use techniques like minification and bundling to help reduce the overall size of the resources that you are sending down the pipe. But what if you didn't even need all of them? What if you had a way to determine exactly which CSS selectors that a given page was using or which functions were being called on a specific page? Well with the CSS and Javascript Code Coverage feature, you do!

To take advantage of this, you'll need to explicitly enable the Coverage tab by clicking on the Ellipsis menu, choosing More Tools and selecting Coverage,

Web Development

Now when you open up your Developer Tools on a page, Chrome will now show you what percentage of the code within that file is actually being used,

SiteCoverage

Finally on top of that, you can click on a specific file within the Coverage tab and it'll show you exactly which lines are and aren't being used within your site,

Web Development

This can be extremely useful in some scenarios as it will allow you to fine tune your resources ensure that you aren't wasting precious bytes by sending down things that you don't need. Now this may not always be the case, but it's certainly an area that you can look to improve.

Full Page Screenshots

If you've ever had the need to reproduce a visual issue with a site, or you might want to make several changes to one and simply needed a mock up to draw on: this one might be for you.

While using the Snipping Tool to continually take a snapshot of a site, scroll a bit more, take another, and then piece those altogether using Paint can work - it usually ends up looking like a horrible mess. Thankfully, Chrome can now automatically take a full-page screenshot of your current viewport using the Device Emulation settings.

To enable this feature, you will need to use Chrome's Built-In Device Emulator which can be found by clicking the mobile icons within the Developer Tools,

Web Development

Now, you should see a slightly different version of your site along with a variety of different filters to emulate different devices. Simply choose the device you want to screenshot using, and choose the Capture Full Page Screenshot option from the ellipsis menu

FullScreenshot

Async Await Step Over

Asynchrony is complicated, and debugging asynchronous snippets of code can really be a nightmare if your tooling isn't there to help you out. Consider you had a section of code like the following:

 

  1. function wait(ms) {    
  2.   return new Promise(r => setTimeout(r, ms)).then(() => "Yay");  
  3. }  
  4.   
  5. // do some work in background.  
  6. setInterval(() => 42, 200);  
  7.   
  8. async function test() {    
  9.   debugger;  
  10.   const hello = "world";  
  11.   const response = await fetch('index.html');  
  12.   const tmp = await wait(1000);  
  13.   console.log(tmp);  
  14.   return hello;  
  15. }  
  16.   
  17. async function runTest() {    
  18.   let result = await test();  
  19.   console.log(result);  
  20. }  

 

In the past, you would be in the middle of stepping through the test()function when your setInterval() code decides to throw a wrench in your debugging and wants your attention. Chrome will now step through from the first line to the last line, despite any other asynchronous calls that are executing consistently, making debugging your async operations and promises much, much smoother.

Wrapping Up

Hopefully from these four features, there may have been at least one that might make its way into your daily (or weekly) repertoire. If not, then when the day comes that you need to do anything resembling the following:

  • Performance tweaking and ensuring no byte goes unused.
  • Ensuring that your async code is working as expected.
  • Checking if your site can survive a massive CDN outage without looking like crap.
  • Get Pam from marketing that huge screenshot of the site to draw on.

You can be confident that there's a tool to do it in your browser and it's just a few clicks away.

Up Next
    Ebook Download
    View all
    Learn
    View all