4 ms·
> It's also usually a lot less responsive for something as simple as a blog. It depends on how much JS is used and what it actually does. Sending and receiving
by KronisLV 5y ago
> It's also usually a lot less responsive for something as simple as a blog.
It depends on how much JS is used and what it actually does. Sending and receiving data in a JSON format as opposed to receiving HTML? Could be marginally faster and would also allow integrating the API for fetching data with other front ends or other consumers easily.
What causes the actual slowdown most of the time is framework code which cannot have the unused bits removed efficiently because of how dynamic most of the languages that we use are, even if there are tree shaking advancements that you hear about every now and then.
That said, it's not entirely hopeless - you certainly can use something like react-snap to pre-render your site and then hydrate it with dynamic content and JS if supported by the user: https://web.dev/prerender-with-react-snap/ https://web.dev/prerender-with-react-snap/
Of course, degradation won't necessarily be graceful - everything that depends on JS simply won't work, as opposed to have some theorethical server-side fallback component, as nice as that would be. I've also heard of server side rendered React, however, even though i haven't personally used it: https://www.digitalocean.com/community/tutorials/react-server-side-rendering https://www.digitalocean.com/community/tutorials/react-serve...
To be honest, trying to achieve such wide support for technologies and graceful fallback logic is a can of worms in of itself, so many simply choose to require JS functionality for their app and don't attempt to support other configurations, which is a shame.
- timw4mail 5y agoI've come to think that such performance increases, if they exist, are not worth the amount of effort compared to a much simpler sever-side render. Also, if your website just happens to have that one bit of information I care about, and I don't view other pages, rendering with Javascript is a complete waste.
- Karrot_Kream 5y agoSvelte [1] is a framework that's all about trying to make interactivity viz. JS a lighter process. It pre-compiles all the code so there's no shadow DOM or similar stuff going on. [1]: https://svelte.dev/blog/svelte-3-rethinking-reactivity https://svelte.dev/blog/svelte-3-rethinking-reactivity