Comments (4)
@vhscom Can you please elaborate on what you mean by "layout thrashing" and why it's an issue?
from sveltekit-blog-starter.
I wasn't familiar with the term, but after searching a bit, I assume it's a reference to this.
If so, I'm not sure whether that applies here or not (or to what extent, if so), given that the "thrashing" would only happen on subsequent navigation, after the initial page load. The first load will be from static HTML that is then hydrated.
I'm sure there's still a performance cost, but I wouldn't think it would be a significant one in most cases (particularly since SvelteKit is already injecting routing by default).
But if there's something I'm missing on that front, I'm definitely keen to hear it.
from sveltekit-blog-starter.
Yep, that's the concept of layout thrashing. You got it. I'm guessing {#key foo}
was added because something wasn't getting updated between page loads? If that's right, you should be able to avoid it by ensuring the props passed into components are triggering the component to update when it should. Is it the worst thing in the world. No, probably not. But it's a pattern we should try and keep out of starters where possible as it'll become a crutch to devs who see it and don't tackle the root cause problem.
Here's an example where I had to use {#key foo}
to destroy a component and I'm still not particularly happy with it. But it's limited to a smaller portion of the page and not the whole page: https://svelte.dev/repl/f9d3e46908904e6ea835a7f1b1e23bbf?version=3.46.4. I think it has something to do with using string and not a unique object such as a Symbol()
as pointed out in the Svelte docs here where they talk about context keys.
Anyway, I just wanted to bring it to your attention as it will hurt the UI and could potentially lead to memory leaks or users losing cursor focus or form data when navigating back and forth between pages. Regardless, nothing is perfect it was just some code smell that jumped out at me as I was looking at starters and thought I'd point it out. 😊
EDIT: To your point about the app being static. Yeah, that probably makes this a non issue unless someone tries to switch adapters. But I haven't looked into it very deeply as I'm just scanning starters right now looking at the great stuff people have made.
from sveltekit-blog-starter.
I'm guessing
{#key foo}
was added because something wasn't getting updated between page loads?
Anyway, I just wanted to bring it to your attention as it will hurt the UI and could potentially lead to memory leaks or users losing cursor focus or form data when navigating back and forth between pages. Regardless, nothing is perfect it was just some code smell that jumped out at me as I was looking at starters and thought I'd point it out. 😊
I appreciate the feedback. The reason is actually just to create a nice transition effect between pages when navigating. I figured it would be simple enough for users to either customize or remove the transition as desired.
I'm going to close this issue for the time being, but I'll keep an eye out for problems that may arise. Please feel free to ping me again if you discover more.
from sveltekit-blog-starter.
Related Issues (20)
- Getting error while trying to build the project HOT 5
- error when trying to install NodeJS (modules) dependencies using npm HOT 2
- Pagination isn't working as expected HOT 3
- Update for sveltekit 1.0 HOT 4
- Prerendered content generates initial 500 status, then 200 on refresh HOT 6
- Quick fix to PostsList component to handle undefined excerpts HOT 3
- Components don't render into built posts HOT 2
- npm run build error HOT 9
- I can't see any markdown posts in the build. HOT 3
- Categories sort HOT 1
- github page HOT 1
- Get svelte components working properly HOT 3
- Atom link in RSS feed HOT 1
- I forked this repo and added features
- `npm run build` fails on tip of main HOT 1
- NavBar missing from the display in the footer HOT 1
- Category won't fully populate for blog posts HOT 1
- npm run build issue HOT 1
- can you share how to install tailwind? the standard installation as explained in the tailwind site doesn't work HOT 2
- Allow plugable themes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveltekit-blog-starter.