DEV Community

Discussion on: Your SSR is slow & your devtools are lying to you

Collapse
 
rxliuli profile image
rxliuli • Edited

I use preact instead of react for small applications to control the overall size of the bundle to improve performance, rather than using more complex build tools or other ssr frameworks for optimization, an example is our personal website. (of course, there is also a reason that it is not complicated and does not require the use of huge ui frameworks or various third-party libraries)

rxliuli.com/

Collapse
 
mxdpeep profile image
Fred Brooker

you should really start using PWA

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

You need to run the mobile page speed test not the desktop one, the reduced CPU power and increased latency that a mobile user may experience is the bit you need to worry about and the mobile test accounts for this with network throttling and CPU slow down.

If you go to page speed insights it will show mobile by default, you still score well 81 / 100 FYI just thought I would give you a heads up as your blocking time from JS is high and could be an easy fix 👍❤️

Collapse
 
rxliuli profile image
rxliuli • Edited

Thanks for the reminder, I simply did some optimizations and it should be better now. The long blocking time of js seems to be caused by markedjs parsing and rendering markdown. Is there a smaller library recommended?

Thread Thread
 
grahamthedev profile image
GrahamTheDev

That is better.

Sadly I am an old school "render it on the server" type of person so I have no recommendations, but perhaps there is a way to "chunk" the page and only render the Markdown that appears above the fold (content visible without scrolling) first and then do the rest in small chunks. That way you won't block the main thread for too long? Just an idea, it might be a nightmare to implement depending on the library you use and your setup.

Either way, 250ms saved on TBT is not to be sniffed at, that is great!

Thread Thread
 
rxliuli profile image
rxliuli

Eventually, I gave up looking for a smaller library of markdown parsers, and instead converted markdown to html during the build phase to avoid the performance penalty of runtime parsing, and it should perform pretty well on mobile as well.

Related plugins: npmjs.com/package/vite-plugin-mark...

Thread Thread
 
grahamthedev profile image
GrahamTheDev

Yeah SSR is the way forward for anything like this, great work hitting that magic 100! It took me longer than 3 hours to fix mine put it like that!

Thread Thread
 
peerreynders profile image
peerreynders

and instead converted markdown to html during the build phase to avoid the performance penalty of runtime parsing

With Astro you should be able to minimize (or delay) the component JS sent to the client to only what's necessary for interactivity (though the migration would be quite a bit more effort).

For the time being Astro considers itself in early beta (0.25.0) focusing on SSG, expanding later to SSR (one experience report).

Thread Thread
 
rxliuli profile image
rxliuli
Collapse
 
bertmeeuws profile image
Bert Meeuws • Edited

I don't see a reason why you would use a framework for this site. This is a one pager

Collapse
 
rxliuli profile image
rxliuli • Edited

In short, I don't want to not use a framework at all, I need jsx to split the page into components, and writing html/css/js purely naked is hard to get used to now. . . In addition, the js bundle is mainly stuck on markedjs, which accounts for 70k of the entire bundle size, and is a cpu-intensive function.

stats.html: file.io/ziBNipcv9Pzd

Thread Thread
 
pavelloz profile image
Paweł Kowalski • Edited

JSX to split page into components? Im pretty sure every templating language has it (ie liquid) and framework is not necessary to do it.

I would go as far as say that 11ty with some liquid is good enough for that and has 0 js served by default.