Re:You might not need JavaScript
by marxidad on Wednesday October 12, 2016 @02:23PM
(#12695312)
The browser doesn't natively support syntax highlighting (they aren't features of HTML or CSS).
[ Parent
| on HN ]
That hardly makes sense. Changing the color of text is definitely a feature of HTML and CSS.
What's the lazy reason for not rendering that before serving the html page.
Re:You might not need JavaScript
by eyelidlessness on Wednesday October 12, 2016 @05:16PM
(#12696476)
It depends what you mean by "support". There are two things a JavaScript syntax highlighter is doing:
1. Classify each token (whether this is building up an AST or doing something more fuzzy/clever is immaterial for this discussion); 2. Construct a DOM tree (HTML) that is styled (CSS).
Step 1 does not have to happen client-side at all. Step 2 doesn't require JavaScript at all.