Browser DevTools Reference

Advanced browser DevTools techniques for debugging, inspection, and frontend troubleshooting.

Console Commands

DOM Selection

// Currently selected element in Elements panel
$0

// Query selector shortcuts
$('selector')           // document.querySelector()
$$('selector')          // document.querySelectorAll() as array

// XPath (when CSS selectors fail)
$x('//div[contains(@class,"component")]/a')

// Find element by text content
[...document.querySelectorAll('*')].find(el => el.textContent.includes('Search Text'))

// Get all links on page
[...document.querySelectorAll('a')].map(a => a.href)

DOM Manipulation

// Make page editable
document.designMode = 'on'

// Remove annoying overlays/modals
document.querySelectorAll('[class*="modal"], [class*="overlay"]').forEach(el => el.remove())

// Kill fixed/sticky elements blocking scroll
[...document.querySelectorAll('*')]
  .filter(el => getComputedStyle(el).position === 'fixed')
  .forEach(el => el.remove())

// Inject CSS
document.head.insertAdjacentHTML('beforeend', '<style>.ads{display:none!important}</style>')

Event Inspection

// All event listeners on element
getEventListeners($0)

// Find click handlers on document
getEventListeners(document).click

// Monitor events on element
monitorEvents($0, 'click')

// Stop monitoring
unmonitorEvents($0)

// Monitor function calls
monitor(functionName)

Debugging

// Set breakpoint on function
debug(object.method)

// Remove breakpoint
undebug(object.method)

// Trace with stack
console.trace('checkpoint')

// Time execution
console.time('operation')
// ... code ...
console.timeEnd('operation')

// Assert (throws if false)
console.assert(x === 5, 'x should be 5', x)

// Group related logs
console.group('API Calls')
console.log('request 1')
console.log('request 2')
console.groupEnd()

// Table view for arrays/objects
console.table(arrayOfObjects)

Object Inspection

// Full object (no truncation)
JSON.stringify(obj, null, 2)

// Copy to clipboard
copy($0.outerHTML)
copy(JSON.stringify(data, null, 2))

// Inspect function source
functionName.toString()

// Get computed styles
getComputedStyle($0).display
getComputedStyle($0).position

// Find all instances of a class (memory debugging)
queryObjects(Promise)

Network Interception

// Intercept all fetch requests
const origFetch = fetch
fetch = (...args) => {
  console.log('FETCH:', args)
  return origFetch(...args)
}

// Intercept XHR
const origOpen = XMLHttpRequest.prototype.open
XMLHttpRequest.prototype.open = function(...args) {
  console.log('XHR:', args)
  return origOpen.apply(this, args)
}

Storage Operations

// Dump localStorage
Object.entries(localStorage)

// Dump sessionStorage
Object.entries(sessionStorage)

// Clear all storage and cookies
localStorage.clear()
sessionStorage.clear()
document.cookie.split(';').forEach(c => {
  document.cookie = c.trim().split('=')[0] + '=;expires=Thu, 01 Jan 1970'
})

Mutation Observer

Watch for DOM changes in real-time:

// Watch all DOM mutations
const observer = new MutationObserver(mutations => {
  mutations.forEach(m => console.log(m.type, m.target))
})
observer.observe(document.body, {
  childList: true,
  subtree: true,
  attributes: true
})

// Stop observing
observer.disconnect()

Keyboard Shortcuts

Key Action

Ctrl+Shift+C

Toggle element picker

Ctrl+Shift+P

Command palette

Ctrl+Shift+M

Device/responsive mode

Esc

Toggle Console drawer

Ctrl+[ / Ctrl+]

Switch panels

Ctrl+Shift+J

Open Console directly

F8

Pause/resume script execution

Elements Panel Tips

Force Element States

Click :hov button to force:

  • :hover

  • :active

  • :focus

  • :focus-within

  • :visited

Toggle Classes

Click .cls button to toggle classes on/off live without editing HTML.

Break on DOM Changes

Right-click element → Break on:

  • Subtree modifications

  • Attribute modifications

  • Node removal

Debugger pauses when JS modifies that element.

Computed Styles

Computed tab shows final calculated values. Click property to see which CSS rule set it (traces overrides).

Network Panel Tips

Useful Filters

status-code:404
status-code:500
larger-than:100k
method:POST
domain:api.example.com
-domain:analytics.com

Copy as cURL

Right-click any request → CopyCopy as cURL

Paste in terminal to replay exact request with headers/cookies.

Throttling

Dropdown menu to simulate:

  • Slow 3G

  • Fast 3G

  • Offline

Initiator Column

Shows what triggered the request (JS file + line number). Click to jump to source.

Application Panel

Storage

  • Local Storage - edit values directly (double-click)

  • Session Storage - same, cleared on tab close

  • Cookies - view, edit, delete per domain

  • IndexedDB - inspect structured data

Service Workers

  • View registered workers

  • Unregister stuck workers

  • Force update on reload

Performance Debugging

// Profile code block
console.profile('myProfile')
// ... code ...
console.profileEnd('myProfile')

// Memory: take heap snapshot
// Performance tab -> Memory -> Take snapshot

// Find detached DOM nodes (memory leaks)
// Take heap snapshot -> Filter: "Detached"