Browser DevTools for Debugging

Beginner · 75 min

Using the Elements, Console, Network, and Sources panels to see what a running web app is actually doing, no matter who or what wrote its code.

Before thisReviewing AI-Generated Code

freeCodeCamp.org · 75 min

Browser DevTools for Debugging

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by freeCodeCamp.orgReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The Elements panel shows the DOM and computed styles as the browser currently sees them, which is often not what the source file says, especially after JavaScript has rewritten the page.
  • The Console surfaces thrown errors, warnings, and anything you deliberately log, and it is usually the fastest way to find the exact line where something broke.
  • The Network panel shows every request an app makes and what came back, which turns "the data isn't showing up" into a specific, checkable fact about a request, response, or status code.
  • The Sources panel lets you set breakpoints and step through real execution, which tells you what a function actually did on this run rather than what you assume it does from reading it.
  • DevTools debugging is independent of who wrote the code — it diagnoses from observed behavior, which is exactly what you need when an AI tool generated the app and you can't yet fully trust your read of its source.

The app doesn’t care what the code says

Every web app you build, whether you typed every line or an AI tool generated most of it, eventually does something you didn’t expect: a button does nothing, a value renders as undefined, a page loads blank. The instinct is to go stare at the source and reason your way to the bug. That works less often than it should, and it works even less well when the code wasn’t yours to begin with — you can read an AI-generated file closely and still miss the part where its assumptions don’t match the page it’s running on. Browser DevTools sidestep the guessing. They show you the actual, running state of the app: the DOM as it exists right now, the requests that actually fired, the exact line where something threw. You stop debugging your mental model of the code and start debugging the thing in front of you.

Elements: what the browser believes is on the page

The Elements panel renders the live DOM, not the HTML file you wrote or generated. Any time JavaScript injects a node, removes one, toggles a class, or recalculates a style, the panel reflects it immediately. This matters constantly with generated code, because frameworks and component libraries often render markup that looks nothing like what’s in the source — a <div> in your file becomes a tree of wrapper elements, a class you set gets overridden by something more specific. Click an element, check its computed styles, and you’ll usually see exactly why a layout is broken: a margin collapsing, a flex property nobody noticed, a stray display: none left over from a conditional that evaluated wrong.

Console: the first place to look, every time

The Console is where uncaught errors land, complete with a stack trace pointing at the file and line that threw. Before touching anything else, open it — an app failing silently almost never fails silently in the Console. It is also where you can run arbitrary JavaScript against the live page: inspect a variable, call a function directly, check whether an object has the shape you expect. console.log statements dropped into suspicious spots turn “something is wrong somewhere in this function” into “the value is wrong by the third line,” which is a much smaller problem.

Network: requests are facts, not opinions

Most app bugs that look like logic problems are actually request problems: a call that never fires, a response shaped differently than the code expects, an API key missing from a header. The Network panel lists every request the page makes, with its method, status code, timing, and full request and response bodies. When an AI-generated frontend and an AI-generated backend don’t agree on a field name or a response shape, this is where the mismatch becomes visible and undeniable — you can see exactly what one side sent and what the other expected.

Sources: watching code execute, not imagining it

The Sources panel is for when logging isn’t enough and you need to watch execution happen. Set a breakpoint on a line, reload or trigger the action, and the browser pauses exactly there, letting you inspect every variable in scope and step forward one line at a time. This is the most reliable way to answer “what does this function actually do with this input,” which is a different question than “what does this function look like it’s supposed to do” — and the gap between those two questions is precisely where AI-generated bugs tend to hide.

Why this comes before testing

Everything later in this roadmap — unit tests, integration tests, end-to-end tests — checks whether code behaves correctly against a known expectation. DevTools is what you reach for before you even know what the expectation should be, when you’re still asking “what is actually happening here.” That skill doesn’t depend on who authored the code, which is exactly why it belongs first: you need a way to verify a running app that works whether you wrote every line or asked an agent to.

Check yourself

  1. 01Why does the Elements panel sometimes show markup that doesn't match the source file?

    It renders the live DOM as JavaScript has modified it at that moment, not the original HTML, so anything added, removed, or restyled by script shows up there even though it's absent from the file on disk.

  2. 02How does the Network panel turn a vague "the app isn't loading data" complaint into something you can actually fix?

    It lists every request with its URL, status code, headers, and response body, so you can see immediately whether the request fired at all, what the server sent back, and whether the problem is the client, the request, or the server.

  3. 03Why is DevTools especially useful when the code in front of you was generated by an AI tool?

    It diagnoses from the app's observed runtime behavior rather than from trusting your read of the source, which matters when you didn't write the code and can't be fully sure what it actually does until you watch it run.

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark