Open source DOM audit

Find the divs your interface doesn't need.

layer-lens-audit checks the page in your browser. It finds wrappers that draw nothing and change nothing, empty elements, and DOM that is too deep or too big, then shows them on the page and in 3D. React, Vue, Svelte, Angular or plain HTML: it reads what the browser rendered.

npm install -D layer-lens-audit

A shop, built the usual way

Components wrap components, and every wrapper adds a div. Some of them hold the layout together; many do nothing at all. The panel lists the ones that do nothing. Hover one to see it on the page, click it to see why it can go and what to do, press 3D to see the tower it builds.

6 products

How it decides

An element is only reported when all of these hold. Anything in doubt stays.

  1. It draws nothing

    No background, border, shadow, outline or ::before, no effect such as clipping, positioning or a transform.

  2. It styles nothing inside it

    No colour or font for its children, no custom properties, no .card > .title rule that goes through it.

  3. Nothing moves without it

    Its box is taken away for a moment and everything around it is measured again. Half a pixel of difference is enough to keep it.

  4. Nothing else needs it

    No role, aria, handler or ref, no :hover, dark mode or @media styles. Ids and test ids are flagged to check.

Use it on any project

Three ways to run it, with the same checks behind each.

Vite plugin

In your app, while you develop

One line in your Vite config, then press Alt + Shift + L on any page.

vite.config.js
import { layerLensAudit }
  from 'layer-lens-audit/vite';

export default {
  plugins: [layerLensAudit()]
};

Runs on the dev server only. Builds don't include it.

Bookmarklet

On any page, without installing

Drag the button to your bookmarks bar, then click it on any page you want to audit.

Sites with a strict Content Security Policy block it.

CLI

On the command line and in CI

Measures the page on a phone and a desktop, and fails the build when new wrappers pile up.

Terminal
npm install -D layer-lens-audit

npx layer-lens-audit \
  http://localhost:4173 \
  --baseline layer-lens-audit.json \
  --max 0

Reports as text, Markdown or JSON.