15

It seems syntax highlighting is not enabled on every SE site, but later on turns out to be rather advantageous. As an example, Graphic Design may not have sounded like needing it, yet there is a feature request, and I think it's justified since many answers have code in them, e.g. JS for InDesign scripts, some GREP-regex and (rather obviously) HTML and CSS. While I'd appreciate having syntax highlighting activate on that specific site (so please upvote Adam's feature request), this question is more general about two points:

  • Why is syntax highlighting disabled on some sites at all? Are the additional resource costs really so high? Couldn't caching improve that then?
  • How to actually proceed when it should become activated on a specific site? It seems feature requests on the specific meta site are not exactly handled quickly (the request mentioned above is from 2013!), and also appear overkill for a simple "please switch that site's config bool for syntax highlighting".

2 Answers 2

9

Why is syntax highlighting disabled on some sites at all?

Bandwidth. TL;DR: though not a big consideration, bandwidth also plays a role here.
Hosting is usually measured by monthly bandwidth, i.e. how many bytes of data are served to the site visitors. Take for example small scale site like cooking. I think everyone agree such site really has no need for syntax highlight/code prettify. Taking a look here, we can see this site has 84,180 visits per day, in average:

Since resources are cached client side, it means only new visitors (or those doing hard refresh) will actually be served a fresh copy, so let's assume 10% of the visits are new, meaning 8000 visitors will be served the syntax highlight resource file, if it will be enabled. If I'm not wrong, the size is about 30kb, so it means 234 MB per day. Monthly bandwidth, only of that file, would be 7 gigabytes, and that's not minor. It's just a drop in the sea, true, but if SE pays per gigabyte, it means money. Money better spent on things that are actually required.

How to actually proceed when it should become activated on a specific site?

Like any other feature request. Can't see why this should get special treatment. The options I know of are:

  • Post in the per site meta.
  • Post here on MSE if it's also relevant for other sites.
  • Send direct message to the team via the "contact us" form or email. (Would likely get a reply "post on Meta", but worth a shot if you already posted on Meta without getting a response and really think it's needed.)
0
10

Why is syntax highlighting disabled on some sites at all? Are the additional resource costs really so high? Couldn't caching improve that then?

The problem is with performance (two additional resources - JS and CSS), these are additional HTTP calls meaning pages load a bit slower. Additionally, the JS needs to run on each and every question page load on sites where it is enabled, the actual work required to highlight is not trivial and takes time (when refreshing a question page the flicker of black -> highlighted can be seen) - we recently tested a different library for syntax highlighting and though it is more accurate and has more supported languages, it is larger and slower and we ended up not using it.

The cost of the additional resources doesn't come into that, nor will caching help with a some of these issues.


I will not comment as to how to proceed, as that was covered well in the answer by Shadow Wizard.

5
  • What about bandwidth? Isn't this an issue? Commented May 25, 2016 at 8:58
  • @ShadowWizard - not as big a consideration as performance, though both are related (larger/more files => worse perf + more bandwidth).
    – Oded StaffMod
    Commented May 25, 2016 at 9:09
  • Thanks, I'm not sure if I should remove it from my answer (leaving only the "how to proceed" part) or not? Commented May 25, 2016 at 9:09
  • 1
    Might as well leave it there (possibly with a disclaimer) - it is a factor, though not the main one. And I think that if people see the numbers, they will get a bit of what we are talking about and the scale involved, @Sha.
    – Oded StaffMod
    Commented May 25, 2016 at 9:11
  • Just a thought, why not dynamically load the syntax highlighting code only when it is actually used? Commented May 25, 2016 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .