Skip to content

Monitor browser API usage to expedite issues discovery (eval, timeouts, intervals, idle callbacks, animation frames, media events & props)

License

Notifications You must be signed in to change notification settings

zendive/browser-api-monitor

Repository files navigation

Browser API Monitor

Whether you're developing a Single Page Application (SPA) and want to assess implementation correctness or are curious about how something works, this tool adds additional functionality to the Chrome browser DevTools to reveal timeouts, intervals, idle callbacks, animation frames and eval usages while mapping their invocation call stacks to a source code location. If the page has mounted video or audio media element's, their events and property state changes can be observed as they happen (documentation, example).

Motivation

To expedite issues discovery, here are some examples from experience:

  • A ~10ms delay interval constantly consuming approximately 10% of CPU from a third-party library, solely to check if the page was resized.
  • A bundled dependency library that utilizes the eval function, thereby preventing the removal of unsafe-eval from the Content Security Policy (CSP) header. It can be arguably intentional, but also may reveal a configuration issue when the package was bundled with webpack config's devtool: 'eval' in production mode.
  • A substantial number of hidden video elements in the DOM that were consuming resources, unexpectedly limited to 100 medias per domain.
  • An unattended interval that was unintentionally left running and contributed to a slowly growing memory.

To explore the internals of a complex systems.

Example

screenshot screenshot screenshot screenshot

Build requirements

  • OS: Linux
  • Node: 20.16.0 (LTS)

Build instructions

make install  # install dependencies
make dev      # build in development mode and watch for changes
make prod     # build in production mode and make extension.chrome.zip