Modern Web Debugging

Spanish audio is available in the player settings
Rate this content
Bookmark

Few developers enjoy debugging, and debugging can be complex for modern web apps because of the multiple frameworks, languages, and libraries used. But, developer tools have come a long way in making the process easier. In this talk, Jecelyn will dig into the modern state of debugging, improvements in DevTools, and how you can use them to reliably debug your apps.

This talk has been presented at JSNation 2023, check out the latest edition of this JavaScript Conference.

FAQ

Some new features in Chrome DevTools for debugging include hiding irrelevant frames in the console and call stack, grouping files by authored and deployed in the sources panel, and using source maps to map compressed files back to their original sources.

In Chrome DevTools, irrelevant frames can be hidden by default during debugging. You can also manually choose to show or hide these frames by clicking on the 'Show More Frames' button in the console or call stack.

A source map is a file that maps compressed versions of your files back to the original source code. Chrome DevTools uses source maps to display your original code during debugging, allowing for a cleaner and more understandable debugging experience.

In Chrome DevTools, you can set conditional breakpoints and logpoints by using command-click on any line in your code. This allows you to set conditions for when a breakpoint should be hit or add logpoints without modifying your code.

Some productivity tips for Chrome DevTools include using the toggle CSS class feature, overriding HTTP response headers, using JavaScript snippets for common tasks, and using the command panel to quickly access DevTools features.

Chrome DevTools uses source map extensions to ignore irrelevant files during debugging. Frameworks and build tools can populate specific fields in the source map to indicate which files should be ignored. You can also manually add files or directories to the ignore list in DevTools.

JavaScript snippets in Chrome DevTools are reusable pieces of code that you can save and run at any time. They are useful for performing common tasks repeatedly. You can save a snippet in the Sources panel and run it using Command+P followed by an exclamation mark and the snippet name.

You can report bugs or issues with Chrome DevTools by visiting the DevTools team's reporting URL or tweeting at @ChromeDevTools. Reporting helps the team identify and fix issues to improve the tool.

To debug minified production code, generate a source map and save it in a secure location. In Chrome DevTools, right-click on any JavaScript file, click on 'Attach Source Map,' and attach your source map to debug the production code.

You can override HTTP response headers in Chrome DevTools by going to the network panel, selecting a request, and editing the headers. This allows you to add or modify headers such as Access-Control-Allow-Origin to continue development without waiting for backend changes.

Jecelyn Yeen
Jecelyn Yeen
29 min
01 Jun, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses modern web debugging and the latest updates in Chrome DevTools. It highlights new features that help pinpoint issues quicker, improved file visibility and source mapping, and ignoring and configuring files. The Breakpoints panel in DevTools has been redesigned for easier access and management. The Talk also covers the challenges of debugging with source maps and the efforts to standardize the source map format. Lastly, it provides tips for improving productivity with DevTools and emphasizes the importance of reporting bugs and using source maps for debugging production code.
Available in Español: Depuración Web Moderna

1. Introduction to Web Debugging and DevTools

Short description:

Hello everyone. Today I'm going to talk about modern web debugging and DevTools. I work in the Chrome DevTools team and share exciting updates about Chrome DevTools. 15 years ago, web development was different. Now we use different languages and frameworks. I'll share tools to improve debugging.

Hello everyone. Yes. So today I'm going to talk about modern web debugging and DevTools. So my name is Jesslyn. This is my handler because I like fish so much. That's why my handler is Jackfish as well.

So I work in the Chrome DevTools team. If every release you did not just dismiss this what's new tab, if you click on it, you might have seen my face before because every new release I will share some exciting news, exciting updates about Chrome DevTools and show you some tips about how to make you be productivity with Chrome DevTools.

So let's start my talk with this screenshot from 15 years ago. So this is the DevTools 15 years ago. You'll notice that there's much less tab, much less panel that you can use. And more interestingly, there's something called crypto as well. So crypto started since that time, but not really. The time, that time when we developed web applications, is so much more different than how we develop web applications now.

For example, back in the time you, when you started we just use HTML, CSS and pure JavaScript to do development. Then after that, we want to improve the performance. Then we start to compress and minify our CSS and JavaScript. Go to the days, now, nowadays what you write is not exactly what the browser reads. For example, you use different languages to write your applications. You use JSX, you use Spark, for example. You use CSS or less for CSS. You use TypeScript to replace JavaScript. And you use a lot of different frameworks as well, like Angular, React and Vue. And we have even meta frameworks like Next and Nuxt as well. And all these tools need to go through a process to compile it and compress it and transform it to what the browsers can understand. And we also need Vue 2 like Vite, Webpack, rollout and ESVue, like a lot of these tools to make everything work.

Now, since the day that we start Web development until now that we are no longer using just HTML, CSS and JavaScript to develop your applications, how about debugging? Do we have any advancement on debugging as well? So, today, I'm going to share with you a few tools to improve your debugging because it is important. This is us. We code for six minutes probably, copy paste, do some research, check GPT or Stack Overflow, paste the code in, but it just doesn't work and we spent six hours to debug it. Okay.

2. New Features for Quicker Issue Identification

Short description:

Let's start with how some of the new features that help you to pinpoint issues quicker. So, one of the things you'll do during debugging is check the console for error logs. Previously, irrelevant frameworks cluttered the console, making it harder to identify issues. Now, we hide the additional frames and show only what's relevant to your application. You can also view the call stack and hide irrelevant frames. Another feature is the ability to view your code first, making it closer to your IDE.

Let's start with how some of the new features that help you to pinpoint issues quicker. So, one of the thing that when you face and you have any issues during the debugging, the first thing probably you will go to is the console to see there is any error log in the console.

So, imagine you go to this page and then you see this console. It doesn't quite helpful when you do development. So, the first screenshot here is a screenshot from the Angular app, and the next one is from Vue.js. So, let me open a sample applications here. Okay.

So, for example, if I click on this increase button. If I open it, this is what we see now. So, previously, if you compare this screenshot, this application on the previous one, you notice that previously, you see a lot of irrelevant frameworks called like Zone.js, Async to Generator.js, like all these irrelevant JavaScript file which is belong to the framework itself. But now, if you open this, what we do is that we hide all the additional frames. All the irrelevant frames just show you what exactly happens in your application, your components. So, for example, you see, like, we show you, like, the problem could be in the app component and the button component. And if you want to see like the framework's code itself, you can click on Show More Frames and to open and check for all the others as well. But you don't have to do it. This is what you see previously. There's a long list until you can identify where is the issues.

Another thing that you can do is that during the debugging, we also improve the... So this is a Vue.js application. During the debugging, you have the same... We have the same features as well. So, for example, I put a breakpoint here. If I click on Add, increase the number. You can see that in the call stack, on the right here, we also hide all the irrelevant frames. We only show you what is relevant. Like, we show you the increment functions, and we show that you're currently in await functions in the increment. And if you want to see all the ignored frames, you can click on this and expand, and you see all the others that are not so relevant to what you are debugging right now. And another new feature that you can try it out is to view your code first. Like, some of the feedback that we get is that, from the view here, like your sources panel here, what you see is what the browser actually reads mixed with what your actual code, when you open it in IDE. So, if you want to see the view that's closer to your IDE, what you can do is click on this file button in the sources panel, select group by authored and deployed.