Repository navigation
feat(web): show a page skeleton while the next page loads - #222
Merged
Merged
Conversation
Slow pages left the old page on screen with no sign a click was taken, so it was clicked again. A same-tab link or form that navigates the document now replaces the main content with a pulsing skeleton after 180 ms; the header and rail stay. Modified, middle, new-tab, download, hash-only and other-origin links, and forms a script handles, do not show it; a page restored from the back-forward cache, a cancelled leave and Escape take it away. The .skel blocks are reusable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #221
What
page-loading.js, loaded bybase.htmlon every page, watches for a click or a submit that replaces the page in the same tab. After 180 ms, unless another handler calledpreventDefault, it puts a skeleton at the top of#main-content: a title, a subtitle line, a row of buttons and five row blocks. The page's own content is hidden undermain[aria-busy="true"]. A hiddenrole="status"onbody, outside the busy region, says "Loading". The next page replaces all of it.No skeleton for: a modifier or middle click, a target other than
_self, adownloadlink, a hash on the same page, another origin or a non-http link, amethod="dialog"form. The skeleton goes onpageshowfrom the back/forward cache, after abeforeunloadprompt, and on Escape. A form's action and target are read withgetAttribute, because a field namedactionshadowsform.action..skelinstyle.cssis the block:--surface-2with a slow opacity pulse, still underprefers-reduced-motion. Later lazy loading of cards, table rows or the rail can use it.Touches
templates and static (
base.html,page-loading.js,style.css) · tests (ui_tests/test_page_loading.py)Before and after
Before, the old page stays as it was until the next one arrives. After, while
/benchmarksloads, delayed by 2.5 s in the test:Verified
In a throwaway rootless
python:3.12container with Node.js and uv, on a copy of the branch:python3 app/tests/parallel.py: 2984 tests in 153 modules, OK.pip install -r app/requirements.txt, thenpython3 app/tests/parallel.py app/ui_tests: 654 tests in 55 modules, OK.test_page_loading.py: Node tests on a small stand-in DOM for which links and forms show the skeleton and what hides it, and a route test that/runs,/benchmarksand/settingsload the script.Browser check, Chromium (Playwright 1.49.1), with the document delayed by route interception: the skeleton shows in light and dark at 1280 and 390 px, and nothing is left after the page arrives. A 10 ms response shows no skeleton. Back and forward leave none. A ctrl-click and a form handled by a script show none. No page JavaScript error.
Not checked in a browser: a page restored from the back/forward cache (Chromium did not cache it under interception; the Node test covers it) and the reduced-motion look.
Risk
downloadthat answers with an attachment or a 204 would leave the skeleton up. No such link exists today.location.href,form.submit()), a reload or a typed address shows no skeleton.base.htmland the styles.