codemirrorcodemirror-modes

CodeMirror: TextMarker vs Mode


I'm experimenting with text annotation in CodeMirror.

What's the difference between using TextMarker and Mode?

It seems that both would be the job done, but the Mode API seems more complicated.

Are there significant performance improvements with Mode?


Solution

  • Yes, highlighting by a mode is computed on demand, whereas making all text in a document to have the right color requires you to do it yourself, and update it yourself whenever the document changes. For big documents, this is going to be very expensive.