I'd like to offer our syntax highlighter library highlight.js for using on the Stack Exchange sites. I am perfectly aware that you already have one in place and there was a similar discussion a while ago, so the burden is on me to explain why you might want to even bother :-)

What's in it for Stack Overflow

  • Better lexing. Correct lexing and parsing is kind of our holy cow. For example we don't confuse regexes with division in CoffeeScript, are able to distinguish method definitions and method calls in Java, know 10 different variants of string syntax in Ruby, etc. I'm not saying we're 100% correct but I do believe we're better at it than any other client-side solution.

  • Better language detection. Here's one example of a mishighlighted code that we correctly detect and highlight as CSS. I actually used to routinely visit Stack Overflow and test our language detection on every code fragment that I stumble upon. Fixed a lot of bugs :-).

  • Support for mixed languages. Templates intermixed with HTML, HTML with embedded CSS and JavaScript — this sort of stuff. A good example is here, for which we can highlight HTML, PHP and JavaScript in the same fragment.

  • More languages. The raw number right now is 103 though quite a few of them a rather obscure. Still, we tend to get support for new and hot languages pretty quickly. Go, Swift, CoffeeScript, F#, Groovy, Scala, etc.

  • The most important thing: we actively work on the project and we have a good development process. Detection tests, markup tests, Travis builds, quick painless releases and a lot of work going into fixing bugs.

What's in it for us

In a word, exposure.

I never actively marketed the library and we got to the point where we have an excellent product but not enough people knowing about it. We have quite a few small and medium-sized sites that use the library but to go further we need someone bigger.

Better exposure also means better exposure of bugs which we could fix and make the library better. I noticed that people using the library on their blogs tend to not report bugs at all and simply ignore them. On Stack Overflow we could even create a custom bug report button to submit mis-highlighted code to our site.

Are you interested?

P.S. Sorry for the possibly awkward language, I'm not used to giving "sales pitches" :-)

  • 6
    One of the very important factors they're also going to look at is overall size. How big is the script in comparison to Prettify?
    – animuson StaffMod
    Oct 23, 2014 at 0:14
  • @animuson In 2011, it was a few KBs smaller than Prettify. Not sure if that's still accurate, though.
    – hichris123
    Oct 23, 2014 at 0:28
  • @animuson I count 14,941 bytes for highlight.js, I couldn't figure out Prettify.
    – Braiam
    Oct 23, 2014 at 0:29
  • The size depends on the languages included in the package. The "common" set of 22 languages is ~35K, the full one may be as big as ~300K but nobody needs that.
    – isagalaev
    Oct 23, 2014 at 1:30
  • Here's the numbers. With all the languages listed on meta.stackexchange.com/questions/184108/… highlight.js is 46K, Prettify is 29K (non-gzipped).
    – isagalaev
    Oct 23, 2014 at 1:41
  • Hmm… Actually, I should say that this size comparison is probably wrong as I looked more closely at the prettify.js linked on StackOverflow and I highly doubt it supports all those languages listed. Some of them may be supported simply as "looks close enough".
    – isagalaev
    Oct 23, 2014 at 3:58
  • 2
    How is it doing speed-wise? Can you offer a real-time preview? Oct 23, 2014 at 16:31
  • @JanDvorak there are two demo links within my question (highlightjs.org/static/stackoverflow/so1.html, highlightjs.org/static/stackoverflow/so2.html), they are real-time highlighting with language detection. In normal cases like these the result is pretty much instantaneous.
    – isagalaev
    Oct 23, 2014 at 17:28
  • 1
    Here's Stack Overflow's response from 2016: meta.stackexchange.com/a/279361/285250 Jun 16, 2020 at 1:08

1 Answer 1


We've officially switched to highlight.js network-wide. See the announcement post for more details.

  • Glad to hear that it has finally happened! 😃 Oct 4, 2020 at 21:34

You must log in to answer this question.

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