Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Defer the toolbar handle position calculation to an animation frame
ensureHandleVisibility() reads handle.offsetWidth during init(), directly
after $$.show(handle) takes the handle from display:none. Layout is dirty
at that point, so the read forces a synchronous document-wide style and
layout flush after the page has already painted. On projects with a large
stylesheet this is slow enough to be visible as a flash of unstyled
content in Firefox.

It only affects a collapsed toolbar, since showToolbar() does not call
ensureHandleVisibility().

Deferring the body to requestAnimationFrame moves the read past the paint.
Behaviour is otherwise unchanged, and the resize listener benefits too, as
repeated events now coalesce to at most one reflow per frame.
  • Loading branch information
novucs committed Aug 6, 2026
commit 3f8b28e015f61c3635a1b0a9531e788990e24da6
18 changes: 10 additions & 8 deletions debug_toolbar/static/debug_toolbar/js/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,16 @@ const djdt = {
}
},
ensureHandleVisibility() {
const djDebug = getDebugElement();
const handle = djDebug.querySelector("#djDebugToolbarHandle");
// set handle position
const handleTop = Math.min(
localStorage.getItem("djdt.top") || 265,
globalThis.innerHeight - handle.offsetWidth
);
handle.style.top = `${handleTop}px`;
requestAnimationFrame(() => {
const djDebug = getDebugElement();
const handle = djDebug.querySelector("#djDebugToolbarHandle");
// set handle position
const handleTop = Math.min(
localStorage.getItem("djdt.top") || 265,
globalThis.innerHeight - handle.offsetWidth
);
handle.style.top = `${handleTop}px`;
});
},
hideToolbar() {
const djDebug = getDebugElement();
Expand Down
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Pending
older versions of Django, the panel explains that upgrading is required.
* Fixed the Django version check in the SQL panel test suite for Django's
boolean parameter handling.
* Deferred the toolbar handle's position calculation to an animation frame,
so it no longer forces a synchronous layout during initialization. On
pages with a large amount of CSS this could briefly show the page before
its styles were applied.

7.0.0 (2026-06-17)
------------------
Expand Down