How Browsers Work and Overview of Browser DevTools
By Flavio
Published · Updated
Tagged: DevTools
Understand browser internals and DevTools: URL to pixels, DOM and CSSOM, layout, paint, compositing, the JS event loop, Core Web Vitals, and inspecting every panel.
Browser DevTools are built-in tools for inspecting and debugging a web page.
Chrome, Firefox, Safari, and Edge all provide them. The panel names and keyboard shortcuts vary slightly, but the core workflow is the same.
This guide uses the names from Chrome DevTools. The official Chrome DevTools overview links to detailed guides for every panel.
Open DevTools
Right-click an element and choose Inspect to open DevTools with that element selected.
You can also use:
Command+Option+Ion macOSControl+Shift+Ion Windows and LinuxF12on many Windows and Linux keyboards
Use Command + Option + J on macOS or Control + Shift + J on Windows and Linux to open the Console directly.
See the official opening instructions for every method.
Elements: inspect HTML and CSS
The Elements panel shows the page’s live DOM, not necessarily the original HTML sent by the server. JavaScript may have added, removed, or changed elements after the page loaded.
Select an element to inspect:
- its attributes and child elements
- the CSS rules that match it
- overridden declarations
- computed styles
- layout information such as the box model, grid, and flexbox
- event listeners and accessibility properties
You can edit HTML and CSS in place to test an idea. These edits affect only the current page in your browser and normally disappear when you reload.
Use the element picker in the DevTools toolbar to select something directly from the page.
Device mode
The device toolbar simulates different viewport sizes, touch input, and device pixel ratios.
It is useful for finding responsive layout problems, but it is not a complete replacement for testing on a real phone or tablet. Real devices have different browsers, keyboards, hardware, and operating-system behavior.
Console: inspect values and run JavaScript
The Console shows messages, warnings, and errors produced by the page.
You can also run JavaScript in the context of the current page:
document.querySelector('h1')?.textContent
Useful console methods include:
console.log(value)
console.table(items)
console.error(error)
console.time('load')
console.timeEnd('load')
Do not paste code into the Console unless you understand it. Code executed there can access the current page and anything your logged-in session can access.
Network: inspect requests
Open the Network panel and reload the page. DevTools records requests made while it is open.
For each request you can inspect:
- URL and HTTP method
- status code
- request and response headers
- cookies
- request body
- response body
- timing information
- the code that initiated the request
You can filter by resource type, search headers and responses, disable the cache, simulate a slower connection, or work offline.
The panel can export a HAR file, which is useful for sharing a network trace. Review a HAR before sharing it because it may contain cookies, authorization headers, query parameters, and response data.
The Network panel guide covers its current tools.
Sources: debug JavaScript
The Sources panel is the JavaScript debugger. I go through stack traces, breakpoints, logpoints, and source maps in The definitive guide to debugging JavaScript.
Set a breakpoint on a line, trigger the behavior you want to inspect, and execution pauses before that line runs. While paused, you can:
- step over, into, or out of functions
- inspect local and global variables
- evaluate expressions
- view the call stack
- add watch expressions
- add conditional breakpoints
You can also pause on caught or uncaught exceptions, DOM changes, event listeners, and network requests.
Source maps connect generated code back to the source files written in TypeScript or processed by a bundler. Make sure your development build produces source maps if you want useful debugging.
Read the Sources panel documentation for the full debugger workflow.
Application: inspect storage and web app state
The Application panel groups browser-managed state and application features, including:
- cookies
- local storage and session storage
- IndexedDB
- Cache Storage
- service workers
- manifests
It can inspect, edit, and clear stored data for the current site. This is useful when an application behaves differently because of stale cache data, an old service worker, or an unexpected stored value.
Storage can contain private data and authentication tokens. Be careful when taking screenshots or sharing exported information.
See the Application panel overview.
Performance and memory
Use the Performance panel to record what the browser does while a page loads or while you interact with it.
The recording can reveal:
- long JavaScript tasks
- excessive rendering work
- layout shifts
- slow event handlers
- animation bottlenecks
Use the Memory panel when you suspect memory leaks or excessive allocation.
Performance recordings are detailed. Start with one specific slow interaction, record only that interaction, and inspect the busiest part of the timeline.
Lighthouse
The Lighthouse panel audits a page for areas such as performance, accessibility, best practices, and SEO.
Treat its report as a starting point, not a guarantee that the page is fast or accessible for every user. Run audits in a clean browser profile when extensions or local state might affect the result.
See the Lighthouse overview.
Changes do not automatically update your source files
Most changes made in DevTools are temporary. Reloading the page restores the files served by your application.
The Changes panel can show edits you made, and local overrides or a configured workspace can persist some changes. For normal development, reproduce the useful edit in your source code and verify it through your application’s build process.
How the browser turns a URL into pixels
DevTools makes far more sense once you picture the pipeline running underneath it.
- Networking: the browser resolves DNS, opens a TCP + TLS connection, sends the HTTP request, and streams back HTML.
- Parsing: the HTML parser builds the DOM tree while CSS builds the CSSOM tree. A plain
<script>pauses HTML parsing until it downloads and runs, so I usedeferorasyncon scripts. - Style and Layout: the browser matches CSS selectors to DOM nodes, combines DOM + CSSOM into the render tree, and computes the exact size and position of every box (Layout / reflow).
- Paint and Compositing: the browser paints text, borders, and colors into layers, then the GPU composites those layers onto the screen.
That last step explains a classic performance rule: animating width or top forces Layout and Paint on every frame, while animating transform and opacity stays on the compositor thread and stays smooth at 60fps.
The main thread and JavaScript event loop
Layout, paint, input handling, and your JavaScript all share one main thread. When a script runs a 250ms synchronous loop, clicks and typing freeze until the call stack clears.
Microtasks (resolved Promises) run immediately after the current call stack finishes, before the browser gets a chance to paint. Keep heavy work broken up or move CPU-heavy computation into a Web Worker so user input stays snappy.
Same-origin isolation
Browsers isolate sites by origin (scheme + host + port) and run different sites in separate OS processes. That boundary stops a random tab from reading your bank’s DOM, cookies, or localStorage, and explains why cross-origin fetch() calls require explicit CORS headers from the server.
Core Web Vitals
When I open the Performance panel or Lighthouse, I look at three real-user metrics first:
- LCP (Largest Contentful Paint): how fast the main hero image or heading appears. Fix it by reducing server response time, preloading the hero asset, and avoiding render-blocking CSS or JS.
- INP (Interaction to Next Paint): how fast the page responds visually after a click or keypress. Fix it by trimming long JavaScript tasks on the main thread.
- CLS (Cumulative Layout Shift): how much the page jumps while loading. Fix it by setting explicit
widthandheighton images and reserving space for late-loading embeds.
Want me to talk about your product? You can sponsor this site.
Related posts about devtool: