preact-cli: All routes are chunked, causing hydration of prerendered pages to flicker
It appears that all routes are being chunked and async loaded, even without the presence of the async!
prefix.
I’ve reproduced this using preact-cli 1.4.1 here: https://github.com/ajoslin/preact-cli-issue-all-routes-chunked. Just build and serve and check the network tab, it loads both bundle and route-home.chunk. And it does a render before the home chunk is loaded.
Details
I have a prerendered homepage. Here’s the process when the user visits the site:
- Index.html loads with prerendered content
- Main JS bundle loads
- Initial render is triggered without the home component downloaded
- Bundle begins downloading route-home.chunk.js
- Wait for route-home.chunk.js is loaded
- Home route chunk loads and the home content renders
Between (2) and (4), a version of the app is rendered that does not include the home route’s content, because the home route’s JS is still loading.
This results in a noticeable “flicker” of the home content being removed then re-appearing as soon as the initial bundle loads.
I’m not using the async!
prefix when importing my home route, but it looks like the home route is being chunked anyway.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 33 (13 by maintainers)
Commits related to this issue
- FIX~! prevent route flickers 🎉 closes #364, #281 — committed to preactjs/preact-cli by lukeed 6 years ago
- Prevent Route Flickers 🎉 (#489) * FIX~! prevent route flickers 🎉 closes #364, #281 * fix linter / copy-paste error — committed to preactjs/preact-cli by lukeed 6 years ago
I got this problem with a latest version
The issue still occurs in latest version
“preact-cli”: “^3.0.0”, “preact”: “^10.3.2”,
As @lukeed explained here, the flickering happens at step 6 ad 7.
@lukeed this can be closed now.
Also, please claim the bounty: https://www.bountysource.com/issues/47899502-all-routes-are-chunked-causing-hydration-of-prerendered-pages-to-flicker
💰
@lukeed I had to go into production without route chunking (I moved all of my routes into
src/components/pages
). I’d like to fix that as soon as this is fixed.I know your time is limited & valuable, so I put a $100 bounty on this issue to hopefully enable you to prioritize it: https://www.bountysource.com/issues/47899502-all-routes-are-chunked-causing-hydration-of-prerendered-pages-to-flicker
I was putting my efforts into #329 – now that that’s done I can actually put effort into this guy. Been on my mind & want to hack at it 😈
Oh, silly. I didn’t pay attention to the Pending status of the
route-home
request. 😅also related #274