News for hackers. Stuff that matters.
Re:Syntax Highlighting in a Webpage Without JavaScript by kelnos on Wednesday March 24, 2021 @10:18PM (#26575838)
It's funny to see us remembering that things can be done on the server. The trend to render everything client-side has always been troubling to me. Such a waste of resources (but it's not your resources, so developers don't care). Sure, things that are truly dynamic or are different for every user is probably usefully done on the client. But a static page with code samples can easily be rendered on the server, with syntax highlighting, and then cached. You only need to do it once, rather than hundreds or thousands of times on every client device.
Re:Syntax Highlighting in a Webpage Without JavaScript by Zababa on Thursday March 25, 2021 @07:47AM (#26579042)
> Such a waste of resources (but it's not your resources, so developers don't care).

I've always wondered if it wasn't intentional. Things running on the client means they don't have to run on the server, and you can save money this way.

Re:Syntax Highlighting in a Webpage Without JavaScript by kevincox on Thursday March 25, 2021 @08:59AM (#26579658)
For things like syntax highlighting which is fairly cheap and done "once" I doubt resource usage is a consideration. However I won't be surprised if this is at least a consideration for bigger companies when they decide to make a relatively cheep API or a server-rendered app.
Re:Syntax Highlighting in a Webpage Without JavaScript by apatheticonion on Thursday March 25, 2021 @05:03AM (#26577863)
The browser is just a generalised client implementation where the application is streamed and sandboxed. It's similar to a native app written on Kotlin/Swift or desktop application written in C#/wpf.

The same logic could be applied to those client application technologies, too.

Re:Syntax Highlighting in a Webpage Without JavaScript by anoncake on Thursday March 25, 2021 @06:50AM (#26578576)
No. The browser is a document viewer, and that's what it's actually good at.
Re:Syntax Highlighting in a Webpage Without JavaScript by phowat on Thursday March 25, 2021 @07:07AM (#26578717)
The browser started as a document viewer. Nowadays it is much more than that.
Re:Syntax Highlighting in a Webpage Without JavaScript by anoncake on Thursday March 25, 2021 @07:44AM (#26579017)
It is not just a crappy "generalized client application".
Re:Syntax Highlighting in a Webpage Without JavaScript by genericstorage3 on Thursday March 25, 2021 @02:03AM (#26576997)
Css will work until a certain point. What do you do when css can't handle?

Give up, do some super hacky unmaintainable css mess, or suck it up and use js...

Re:Syntax Highlighting in a Webpage Without JavaScript by setr on Thursday March 25, 2021 @02:57AM (#26577209)
The trouble generally is that JS is used despite the content being static, or independent of client behavior/usage.

That is, JS can be used to do everything but it is not optimal, or even near optimal (or even remotely close to) for many use cases. In terms of runtime or simplicity. But because it is capable and available, it has encroached into every niche (of html/css) until like any invasive species, it consumes and shreds through all available resources, collapses the whole ecosystem, and all complex creatures give way to a fresh start with new fairly rudimentary biology (wasm) trying to evolve towards and find a new stability point — hopefully one that does not invite a similar destructive species, but we’ll see how it goes

Re:Syntax Highlighting in a Webpage Without JavaScript by genericstorage3 on Sunday March 28, 2021 @08:44PM (#26616477)
For example you can do a drop down menu in css. Then you have some new requirements that css alone can't do it.

Even a basic thing, could be impossible in css.

All your css logic goes to trash. Or you can keep css logic and make a mess of a software

If you have done it in js, you'd be able to reuse some code.

Re:Syntax Highlighting in a Webpage Without JavaScript by fwip on Thursday March 25, 2021 @11:59AM (#26581889)
What do you mean, "can't handle?"

How do you plan to style it with javascript without CSS? Rendering directly to canvas?

Re:Syntax Highlighting in a Webpage Without JavaScript by tantalor on Wednesday March 24, 2021 @11:29PM (#26576283)
Offloading rendering to CSS is still making the client do some work. Excessive CSS can bloat the page, hurting latency.

If you take this approach to the extreme, you should render to png on the server for display, and provide plain text for accessibility only.