Twitter | Search | |
@rem
Do you think syntax highlighting (in blog posts, examples, etc) be in >(poll)< I've always err on the side of client as it's a progressive upgrade, not particularly costly on the client, and reduces markup downstream.
Reply Retweet Like More
Charlie Don't Surf 1 Apr 19
Replying to @rem
Server side. Quicker to render to client, no flash of unstyled code, robust.
Reply Retweet Like
@rem 2 Apr 19
Replying to @sonniesedge
To nitpick, arguably there's a flash of unstlyed content either way. With server rendered, colours are loaded in the client. In client, text is swapped and coloured in the client. Visual content should remain exactly where it always was and always visible —
Reply Retweet Like
Jake Archibald 2 Apr 19
Replying to @rem
Client side: ➡️ Serve HTML. ➡️ Serve CSS. ➡️ Serve JS. ➡️ Execute JS. Server side: ➡️ Serve HTML (a tiny tiny bit more). ➡️ Serve CSS. The latter wins every time. Why make every user run code on every load when it has the same output?
Reply Retweet Like
@rem 2 Apr 19
Replying to @jaffathecake
It's that "tiny tiny" bit more that I want to put under the microscope. But aye, I agree fully with you (and others giving their justification for server side). No one as yet has given a good reason to render client side (I can think of one, but it's not been suggested yet)
Reply Retweet Like
Amelia Bellamy-Royds 1 Apr 19
Replying to @rem @anatudor
I've been meaning to write up a proposal for native HTML syntax highlighting, if only because it would make it easier for people to be able to always see code in their favourite colour scheme!
Reply Retweet Like
@rem 1 Apr 19
Replying to @AmeliasBrain @anatudor
There is language support (as little as that means) in the html spec around the PRE tag. It's odd, but it recommends using the class attribute
Reply Retweet Like
Chris Ferdinandi ⚓️ 1 Apr 19
Replying to @rem
I do server-side because there’s no flash of unstyled content that way, and markup is far less costly for a browser to parse JavaScript is.
Reply Retweet Like
Digggid 3 Apr 19
Replying to @ChrisFerdinandi @rem
if you use postMessage you can go serverless but i havent thought into security yet...
Reply Retweet Like
Phil Hawksworth 1 Apr 19
Replying to @rem @eleven_ty
I do it server side at build time. Because anything I can do ahead of time, I do ahead of time. It doesn't add markup for me as it is done by my SSG () during the build. One less thing to have as a client-side js dependency and on the render path.
Reply Retweet Like
Matt Gaunt 1 Apr 19
Same here. Especially if you want to support several languages.
Reply Retweet Like