Open jordesign opened 2 years ago
The hydration is happening on the load
event:
It's necessary for sites that load the scripts before the HTML. Moving this script to the footer will probably make this unnecessary, and therefore the hydration will occur faster. However, it is still not ideal since this script (and any other like it) should be loaded asynchronously to avoid blocking the main thread while the browser is finishing the HTML/CSS rendering.
I think the only solution that would make sense in the long term is to delay the hydration as much as possible in the main thread (using an async
script + requestIdleCallback
hydration) but capture the click
event. If the user clicks before the hydration, it still works (with a delay, but it works).
This is what Qwik is doing for all the event listeners, but I've also seen it in the Rocket hydration techniques, so maybe we can get some inspiration from there. There's a proposal for supporting this natively, which is promising.
Do you have any other idea @jordesign?
A bit off-topic, but we are investigating how to add Partytown to WordPress, which will remove the load of third-party scripts in the main thread.
EDIT: Yesterday, I proposed the async/defer
functionality in https://github.com/WordPress/gutenberg/issues/41236#issuecomment-1134758794, and I've just added the onClick
hydration technique to the Block Hydration Experiments tasks.
Description
The Mobile/Hamburger menu button is not working properly when the site is slow to load.
I expected: to be able to use the mobile menu before the page and assets are fully loaded.
What Happened: mobile menu button was blocked from working until the page (and third-party scripts) were fully loaded.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
WP 5.9.3
Happens with GB deactivated, and also with GB 13.2.1 active
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes