-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve HTML rendering performance #2476
base: main
Are you sure you want to change the base?
Improve HTML rendering performance #2476
Conversation
Couple lines of CSS cut page loading and resize times by 100 times (on my machine). Description of what content-visibility is: https://web.dev/articles/content-visibility Basically browser now doesn't render/layout invisible sections. As a downside it makes scrollbar jump around slightly when you scroll the page, as browser recalculates the layout. Section size was calculated using the following JS code: const getAverage = (arr) => arr.reduce((p, c) => p + c, 0) / arr.length getAverage(Array.from(document.querySelectorAll(".sect1").entries().map(([idx, el]) => el.getBoundingClientRect().height ))) getAverage(Array.from(document.querySelectorAll(".sect2").entries().map(([idx, el]) => el.getBoundingClientRect().height )))
By "invisible" do you mean, not currently appearing in the browser window? |
Yes, you can read more about it on that link. |
Converted to a draft for now as there is a problem that if you open a page through URL with |
I have some WIP to turn the VU sections into collapsible blocks and auto-expand them when landing on them via a #anchor, via a JS fragment run on pageshowHashEvent, so there is very possibly another interaction here as well. Not ready for turning into an MR yet but wanted to give you a headsup. |
Also to note, getting this stuff working cross-browser and cross-platform is a right pain. Safari in particular seems to handle some of this stuff less robustly / inconsistently with desktop browsers. What you're doing here appears pretty straightforward but how it will interact with the layout algorithms and assumptions in different browsers needs to be established. |
I found the issue, it was very simple, the problem was in that There is still a problem that content may shift slightly after you refresh the page, but it is a minor issue, that may be a browser bug.
Thanks for a heads-up, that will need to be tested too indeed. I think for collapsible sections it may be better to set content visibility to Actually if every big section was collapsed there wouldn't be any scrollbar jumping at all, and navigating the page would be easier, that is worth considering. At least collapsing
Yes, @oddhack I also have a question, that khronos.css is only used in single page documents, right? Just so I wont break anything else. |
I'm not sure how you mean "single page documents"? It's used in the HTML artifacts created out of the repository, but not in the Antora site at docs.vulkan.org, which has a different styling system, if that answers the question. |
Couple lines of CSS cut page loading and resize times by 100 times (on my machine).
Description of what content-visibility is: https://web.dev/articles/content-visibility Basically browser now doesn't render/layout invisible sections. As a downside it makes scrollbar jump around slightly when you scroll the page, as browser recalculates the layout.
Section size was calculated using the following JS code:
const getAverage = (arr) => arr.reduce((p, c) => p + c, 0) / arr.length getAverage(Array.from(document.querySelectorAll(".sect1").entries().map(([idx, el]) => el.getBoundingClientRect().height ))) getAverage(Array.from(document.querySelectorAll(".sect2").entries().map(([idx, el]) => el.getBoundingClientRect().height )))
This is useful for single page HTML spec with all extensions specifically.
Scrollbar jumping can be improved by specifying different intrinsic size for each section, or with some JS code, but I reasoned that it doesn't really matter much.