mrobinson · GitHub

Instead of walking the entire tree every time an `<iframe>` is attached
to the DOM, just walk forward from its insertion point to find the
subsequent `<iframe>`. Then add the new `<iframe>` before that
`<iframe>` in the list. This optimizes the case of parsing, where there
are few or no DOM elements after a freshly added `<iframe>`.
In my profiling of the test case from servo#38289 this seems to reduce the
time that `Window::get_iframe_viewport_details_if_known` takes during
loading and showing the page from 55.8% to 37.7%.
Signed-off-by: Martin Robinson <martin@abandonedwig.info>

@mrobinson

Open

TimvdLippe

@TimvdLippe

@mrobinson

@mrobinson mrobinson changed the title script: Directly modify IframeCollection on tree changes script: Directly modify IFrameCollection on tree changes

May 29, 2026

@mrobinson

@mrobinson

mrobinson deleted the improve-iframe-insertion-performance-2 branch

May 29, 2026 21:34

Read the original on github.com ↗