Course contentsShow
← Web Development
Lesson 2265 of 2,98241. Debugging TechniquesFree lesson

Breakpoints in Minified Code

Navigate and set breakpoints in production code using source maps and pretty-printing features.

Breakpoints in Minified Code

You'll learn how to effectively debug production-ready code that's been compressed and minified by using source maps and pretty-printing features.

When your code reaches production, it's often minified—compressed into unreadable, single-line blocks to reduce file size. Trying to set breakpoints in this code feels like debugging alphabet soup. Fortunately, DevTools provides two powerful tools to make this manageable.

Pretty-Printing: The Manual Approach

If source maps aren't available, you can click the {} (pretty-print) button at the bottom of the Sources panel. This reformats minified code into readable, indented JavaScript. While variable names remain cryptic (a, b, xyz123), you can at least see the structure and set line-of-code breakpoints that make sense. Think of it like uncrumpling a wadded-up letter—the handwriting is still messy, but at least you can read line by line.

Source Maps: The Professional Solution

Source maps are special files (.map) that create a bridge between your minified production code and your original source files. When present, DevTools automatically loads them and displays your original, readable code in the Sources panel. You set breakpoints in the original code, and they work seamlessly even though the browser is executing the minified version.

It's like having a translator who instantly converts dense legal jargon back into plain English while you read.

Practical Workflow

  1. Open the Sources panel and locate the minified file
  2. Check if DevTools shows your original file (source maps working) or offers the {} button (pretty-print available)
  3. Set breakpoints as you normally would—DevTools handles the mapping
  4. Step through code execution using the same debugging controls you already know

Key Takeaway: Use source maps in production builds to debug original code, or fall back to pretty-printing when source maps aren't available—both techniques let you set meaningful breakpoints in otherwise unreadable minified code.