-
Notifications
You must be signed in to change notification settings - Fork 596
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
Safari 11: Whole page re-render on navigate — what am I doing wrong here ⁉️ #636
Comments
This is a stupid issue because I didn’t give sufficient contex to lead to a solution or fix, sorry. |
Heya, sorry this is happening! - the short answer is: we need to make use of the cache. There's two options here, and it's up to you to pick the one that's best for you:
Hopefully this is somewhat helpful; apologies again you've run into this! |
Hey @yoshuawuyts, thanks for responding. I was experimenting with the caching-dom-elements feature on Sunday. I was able to totally bungle up my UI and stop arbitrary things from refreshing, so that told me did in fact work. I think my issue is that I didn't have a tagged template string attached to a variable name that I could define I think it makes sense to use I tried to use yo-yoify and babel's env presets for a while, and in the process looked at the bundled files for a bit, but I was never able to narrow down exactly what was causing the different behavior in chrome or safari. As far as I can tell it's not a transpiling or bundling issue. I think that there may be something that doesn't work as intended with nanomnorph and safari (11.03 in my case). My hunch is that my particular Dom tree is pretty easy to diff since it's a series of uniquely-named images wrapped in similar tags. Another possibility is that I have two image grids defined in two different page layouts, and that fact alone is causing a re-render regardless of whether they produce the same Dom elements. I am going to try to rule that out next, but someone more experienced than me on inspecting how the framework is working in Safari would be better at that task. :) |
I updated |
Caching manually sounds great, but why does it work properly in Chrome and not in Safari? |
Here's a wild guess but are you by any chance using So during initial page load the correct var img = document.createElement('img')
// Safari will start fetching this right here ↓
img.setAttribute('src', '/some-image.jpg')
// Chrome et.al., for some reason defers preload until here ↓
img.setAttribute('srcset', '/some-small-image.jpg 500w, /some-large-image.jpg 1000w') If this is the cause of your problem, simply changing the attribute order should solve the issue. - <img src="/some-image.jpg" srcset="'/some-small-image.jpg 500w, /some-large-image.jpg 1000w">
+ <img srcset="'/some-small-image.jpg 500w, /some-large-image.jpg 1000w" src="/some-image.jpg"> Edit: also, if you have defined |
@tornqvist I didn't use Last night I ran a slightly older build on the RasPi. There I did not notice the bug with too many requests. This is exciting because now I can diff and exchange various pieces of the code to narrow down the source of the difference. My next step is going to be to take the two copies of the app in each installation and diff the package-lock file and bundles, and perhaps trade bundles between machines to try to find what piece is the source of the isssue. |
After diffing the bundles I saw that babel was merely transforming the template strings and template functions, which safari supported anyway. With or without babel I got the same results. I also learned that a cache header on the RasPi from nginx was eliminated the requests. The good news is that I can basically ignore this bug and use the cache headers to eliminate the requests. The bad news is that I still don't know why Safari isn't working well with this version of Choo. |
Expected behavior
Only 1 image request, modal renders but most elements untouched.
Actual behavior
every page image requested, whole body seems to re-render.
Steps to reproduce behavior
Navigate between two pages with an additional/less dom element tree.
Safari 11.03 exhibits the problem. Adding yo-yo-ify doesn't solve it.
Chrome only requests 1 image, and doesn't seem to re-render everything.
After months using this framework for my app I discovered that my nginx and caching were hiding the fact that the app was constantly re-rendering the entire body element and everything inside. It's requesting every image in my gallery grid each time I switched images in the Lightbox view.
I was under the impression that morphdom would compare the trees—which are nearly identical—and only render the Lightbox. I probably have something set up incorrectly, or I'm making incorrect assumptions about how the framework works. I have spent hours going over the handbook and figuring out server-side rendering and re-hydration, but now I'm running into another issue where I can't find any examples, guides, discussion, or any evidence this has been done before or anyone has opened the browser tools to see what is really going on.
I think the problem isn't that the framework is obtuse, but the the handbook and documentation are not adequate to onboard new users. There aren't examples of complex apps built with this.
The text was updated successfully, but these errors were encountered: