-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Missing Content message flashes on initial load #42
Comments
Prototype detailsHere's a prototype where I made the following changes as a proof-of-concept:
Testing the prototypeThe prototype only has a single URL: https://5e1fe334cd8a9f0008d3412a--elm-pages.netlify.com/blog/introducing-elm-pages/ You can run through manual tests with it here. In Chrome, I recommend the following settings:
TODO
|
I've been thinking a bit about this, and I think I have another solution.
My only worry here is, will users see a "flash" when the content is being replaced? |
Hello @icidasset, thanks for chiming in! That's actually exactly what's happening in the prototype I have here: https://5e20f901469a7c0008528294--elm-pages.netlify.com/blog/introducing-elm-pages/ You can see the moment when Elm takes over is when the counter starts going up (if you throttle your connection, you can see it even better). There was some discussion in the Elm slack by the way about the idea of not calling the user's If you pull up that link and open up your favorite browser performance inspection tools, I'd love to hear what you think of the current state! It seems pretty smooth other than a small flash of the image when Elm takes over (I'm sure there are other blemishes for different types of content like animations, for example, since Elm is actually considering the DOM to be brand new rather than adopting the old one). |
Oh, for real? Great 😄
Yeah, that seems like a great idea, could possibly prevent some weird situations.
It does feel pretty smooth yeah! |
Here are some ideas on how to approach this.
What's happening now
<script>
tag that includes the Elm bundle is in the<head>
, and doesn't have adefer
on it, I believe it will block the rest of the HTML from rendering? (need to confirm this)content.json
file, which contains the body of our content, as well as anyStaticHttp
data for the page:elm-pages/src/Pages/Internal/Platform.elm
Line 156 in 7eaea5d
Possible solution
<script defer ...>
?).elm-pages
init
that contains already-fetchedcontent.json
data (could either hardcode that data into the generated HTML file, but probably best and most performant to fetch it once the HTML is rendered, and then callback once it's fetched to init the elm app with that data as a flag).Old solution idea
What could happen instead (this is just one solution path)I thought this would be a good approach, but thought of the simpler solution above<script defer ...>
?).<div>
(will this cause rendering to differ at all? Probably not because it's Elm, right, so it should render reliably even off in an invisible div?).view
function in the invisible<div>
to be called... can use the MutationObserver technique similar to howelm-pages
currently listens for page changes in order to know when the URL has changedelm-pages/index.js
Lines 72 to 84 in 5754bfb
The text was updated successfully, but these errors were encountered: