Chrome DevTools
Checking access...
Chrome DevTools is the most important tool in a web developer’s arsenal. It lets you inspect, debug, profile, and optimise your web applications.
Tip
Open DevTools with F12 or Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (Mac).
Elements Panel
Inspect and modify HTML and CSS in real time.
Inspecting Elements
Right-click any element → Inspect to open DevTools with that element selected.
- Styles pane: See all CSS rules affecting the element, including inherited and computed styles
- Box model diagram: Visual padding, border, margin
- Computed tab: Final computed values for all properties
- Event Listeners tab: See all event listeners attached to the element
Live CSS Editing
/* Click any property value to edit it *//* Changes are live but temporary — refresh to reset */
/* Toggle rules on/off with checkbox *//* Add new rules by clicking between brackets *//* See specificity with the coloured circle indicators */CSS Tricks
- Force state: Right-click an element → Force State →
:hover,:active,:focus,:visited - Copy selector: Right-click a rule → Copy → Copy selector
- Find CSS source: Click the filename link next to any rule to open the Sources tab
- Filter CSS: Type in the filter box above the Styles pane to find specific properties
Console
Logging Levels
console.log("Basic info");console.info("Informational");console.warn("Warning message"); // yellowconsole.error("Error message"); // red with stack traceconsole.debug("Debug message"); // verboseUseful Console Methods
// Tabular dataconsole.table([ { name: "Alice", age: 30, role: "Admin" }, { name: "Bob", age: 25, role: "User" },]);
// Group related logsconsole.group("User Details");console.log("Name:", user.name);console.log("Email:", user.email);console.groupEnd();
// Timingconsole.time("fetch-users");await fetchUsers();console.timeEnd("fetch-users"); // "fetch-users: 234ms"
// Count occurrencesfunction handleClick() { console.count("Button clicked");}
// Stack traceconsole.trace("Where was this called from?");
// Styled logsconsole.log("%cStyled message", "color: blue; font-size: 20px; font-weight: bold");$ Commands
$0 // Last inspected element$1 // Second-to-last inspected element$$("div") // querySelectorAll shorthand$x("//div") // XPath query$_ // Last evaluated resultNetwork Tab
Inspect all network requests made by the page.
Key Features
- Waterfall view: See request timing (DNS, TCP, TLS, request, response)
- Filter by type: XHR/Fetch, JS, CSS, Img, Media, Font, Doc, WS
- Search: Search across all request/response bodies
- Block requests: Right-click → Block request URL to simulate missing resources
- Replay: Right-click → Replay XHR to re-issue a request
- Copy as fetch: Right-click → Copy → Copy as fetch
Throttling
Simulate slow connections:
- Go to the Network tab
- Click the throttle dropdown (default: “No throttling”)
- Select “Slow 3G” or “Fast 3G”
- Or add custom profiles with specific bandwidth/latency
Checking Request Details
// Headers: request and response headers// Payload: POST request body// Preview: Formatted response (parsed JSON, rendered image)// Response: Raw response body// Timing: Detailed timing breakdown// Cookies: Cookies sent with the requestSources Tab (Debugger)
Set breakpoints and step through JavaScript code.
Types of Breakpoints
| Breakpoint Type | How to Set | Use Case |
|---|---|---|
| Line breakpoint | Click line number | Pause at specific line |
| Conditional | Right-click line → Add conditional | Pause only when condition is true |
| DOM breakpoint | Elements panel → right-click → Break on | Pause on subtree modification, attribute change, node removal |
| Event listener | Sources → Event Listener Breakpoints | Pause when specific event fires |
| XHR/fetch | Sources → XHR Breakpoints | Pause when URL contains a string |
Debugging Workflow
- Set a breakpoint on the line you want to inspect
- Trigger the action that runs the code
- Execution pauses — now you can inspect
Controls:
| Button | Shortcut | Action |
|---|---|---|
| ▶️ Resume | F8 | Continue execution |
| ⤵️ Step Over | F10 | Execute current line, go to next |
| ⬇️ Step Into | F11 | Enter a function call |
| ⬆️ Step Out | Shift+F11 | Exit current function |
| 🔄 Restart | — | Restart execution at current frame |
Watch panel: Add expressions to track their value across breakpoints. Scope panel: See all local, closure, and global variables.
Performance Tab
Record and analyse runtime performance.
Recording
- Open Performance tab
- Click the ⏺ Record button
- Interact with your page
- Click Stop
Interpreting Results
- FPS chart: Green bars at top = smooth. Red bars = jank (frame drops)
- CPU chart: Which operations are consuming CPU time
- Flame chart: See the call stack over time — wide bars = long operations
- Summary: Time breakdown (Scripting, Rendering, Painting, System, Idle, etc.)
Common Performance Issues
- Forced reflows: Reading layout properties (like
offsetHeight) after changing styles - Long tasks: Main thread blocked for > 50ms
- Layout thrashing: Repeated read/write cycles forcing multiple layouts
- Excessive DOM size: Too many elements in the DOM
Lighthouse Tab
Automated audit for performance, accessibility, SEO, and best practices.
// Generate a report// 1. Open Lighthouse tab// 2. Select categories (Performance, Accessibility, Best Practices, SEO)// 3. Click "Generate report"// 4. Review scores and recommended fixesCore Web Vitals
| Metric | Good | Needs Work | Poor |
|---|---|---|---|
| LCP (Largest Contentful Paint) | ≤ 2.5s | 2.5-4.0s | > 4.0s |
| FID (First Input Delay) | ≤ 100ms | 100-300ms | > 300ms |
| CLS (Cumulative Layout Shift) | ≤ 0.1 | 0.1-0.25 | > 0.25 |
Memory Tab
Detect memory leaks by recording heap snapshots:
- Go to Memory tab
- Select “Heap snapshot” → Take snapshot
- Perform actions in your app (open/close modals, navigate)
- Take another snapshot
- Compare snapshots — look for retained objects that shouldn’t exist
Signs of a memory leak:
- Heap size keeps growing after repeated actions
- Detached DOM elements (elements removed from DOM but still referenced in JS)
- Event listeners on detached elements
Quick Reference
| Panel | Use When You Need To |
|---|---|
| Elements | Inspect/edit HTML and CSS |
| Console | Log data, run JS, debug |
| Network | Debug requests, check API responses, throttle |
| Sources | Step through JS with breakpoints |
| Performance | Profile runtime performance |
| Lighthouse | Run audits and get improvement suggestions |
| Memory | Find memory leaks |
| Application | Inspect storage, cookies, caches, manifests |
Practice Exercises
Network debugging: Open the Network tab and visit a website. Filter to only XHR requests. Find a JSON API call and inspect the response. Try throttling to Slow 3G and reload.
Debugger walkthrough: Write a small script with a bug (e.g., off-by-one in a loop, undefined variable access). Use the Sources tab to set breakpoints, step through the code, and identify the bug by inspecting variables.
Performance audit: Run Lighthouse on your own site (or a test page). Note the Performance, Accessibility, and Best Practices scores. Pick one improvement suggestion and implement it.