Divi React Scan
Run React Scan inside the Divi 5 Visual Builder — both the builder UI and the canvas iframe the Chrome extension can't reach.
by eduard-un · github.com/eduard-un/divi-react-scan · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/eduard-un/divi-react-scan/archive/refs/heads/main.zipRuns one React Scan instance across both React trees in the Divi 5 Visual Builder:
- the builder panels in the top window;
- page modules in the same-origin
#et-vb-app-frameiframe.
The toolbar and overlay live in the top window. Divi registers the iframe's React renderer on the parent's DevTools hook, so one instrumentation receives commits from both renderers.
Why the React Scan bundle is patched
Stock React Scan can receive iframe commits through a shared DevTools hook, but
it treats every host element's rectangle as if it belonged to the overlay
window. An iframe element's getBoundingClientRect() is relative to the iframe
viewport, so outlines are offset and mis-scaled when Divi:
- leaves room for the builder and page bars;
- centres tablet and phone previews;
- applies preview zoom with
transform: scale(...).
The vendored bundle maps and clips same-origin iframe rectangles into the top viewport before drawing. It also performs deep iframe hit-testing for the inspector and reacts to iframe scrolling, resizing, and style-based zoom.
It additionally fixes an upstream toolbar rendering bug: React Scan's Tailwind
stylesheet lives in a shadow root, where browsers ignore its @property
registrations, so the power toggle's knob dropped out of its track when scanning
was off and element borders went missing.
This is a source patch, not a runtime monkey-patch of minified internals.
See patches/README.md for its exact upstream commit, hash, and rebuild steps.
Install
Copy this directory into wp-content/plugins/ and activate it. The built asset
is committed; installation needs no package manager or build step.
Requirements
- Divi 5.x Visual Builder
define( 'ET_DEBUG', true );inwp-config.phpfor readable component names
When ET_DEBUG is off, the plugin forces React Scan to run against Divi's
production React build and warns that component names will be minified.
Runtime design
All plugin assets load only in the top Visual Builder document and only for a
user who can edit posts. They load in <head> before Divi's footer React
scripts, so the parent DevTools hook exists before either renderer initializes.
The app-frame request loads no React Scan assets. Divi's own footer script
assigns the iframe DevTools hook to the parent hook. That assignment is
required; the previous two-instance design blocked it with hook-guard.js.
React Scan's auto bundle starts once while evaluating. Options are seeded in
localStorage["react-scan-options"] before it loads because calling
window.reactScan() afterwards would start a second instrumentation.
useOffscreenCanvasWorker is disabled: iframe scroll and zoom changes update
the live outline geometry held on the main thread.
Toolbar
There is one toolbar, initially at bottom-right. Existing React Scan toolbar settings are preserved, so a dragged position survives reloads. Its power toggle controls both React trees.
Turning it off
- Use the toolbar's power toggle.
- Append
?rscan=0to the Visual Builder URL. - Define
DIVI_REACT_SCAN_DISABLEastrue.
Manual verification
- Open the Visual Builder and confirm one toolbar.
- Type in a settings field; the panel should outline accurately.
- Edit a module; its canvas element should outline accurately.
- Repeat in desktop, tablet, and phone previews.
- Repeat at non-100% preview zoom and while scrolling the canvas.
- Use the inspector on both a panel and a canvas module.
- Confirm React DevTools still lists both trees.
- Add
?rscan=0and confirm neither document loads React Scan assets.
Tests
Run manually:
node --test assets/__tests__/
php -l divi-react-scan.php
Licence and attribution
This plugin is GPL-2.0-or-later. See LICENSE.
assets/react-scan.js is a modified build of React Scan 0.5.7 by Aiden Bai and
contributors, distributed under the MIT licence. The source patch and upstream
licence notice are retained in patches/.
Divi is a commercial theme by Elegant Themes and is not included here.