Live data from Hacker News

Syntax Highlighting in a Webpage Without JavaScript

fctorial.github.io

21–30 of 44 posts

Re: Syntax Highlighting in a Webpage Without JavaScript

#22
post #15

Earlier quoted context omitted.

There's a increasingly larger amount of web developers who are only "trained in React/Angular/Vue" and are unable to understand how to use or the trade-offs of regular websites using just HTML+CSS with only a little or no JS (that goes for both templated or fully static sites), and a surprising number of them even thinking they are some kind of "legacy technology". At the very least, this kind of article is informati…

I'm fascinated by this. It seems that for any developer with less than five years of industry experience there's a reasonable chance that they've almost exclusively worked in an SPA, JavaScript-for-everything environment. I have a hunch that there are a lot of web professionals out there these days who genuinely don't know how to build a web application without JavaScript - POST forms, cookies and the like.

This is why we end up with a new reinvention of make every five years.

The churn rate on junior developers is probably the single biggest factor in software over the past two decades.

Re: Syntax Highlighting in a Webpage Without JavaScript

#23
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

#25
So many HNers pointing out that it was possible since the dawn of the web... yet the point of this article is that you can just add highlighting JS and constexpr.js will automatically optimize it. JS-based highlighters have all sorts of plugins, so it makes sense to reuse the effort.

So basically the script renders the JS-needed website, execute the JS as a build step and spit out the highlighted site. Pretty cool!

Re: Syntax Highlighting in a Webpage Without JavaScript

#27
post #23

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 s…

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.

Re: Syntax Highlighting in a Webpage Without JavaScript

#29
post #23

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 s…

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

#30
post #3

What is so special about this? This is the way websites have been doing syntax highlighting before people started using javascript libraries.

There's a increasingly larger amount of web developers who are only "trained in React/Angular/Vue" and are unable to understand how to use or the trade-offs of regular websites using just HTML+CSS with only a little or no JS (that goes for both templated or fully static sites), and a surprising number of them even thinking they are some kind of "legacy technology". At the very least, this kind of article is informati…

I think it's wasted work/experience as css alone can't do everything.

Then you'll end up having a project with highlighting logic in css and js. That's less than optimal

Post reply on HN