shiki icon indicating copy to clipboard operation
shiki copied to clipboard

What Settings can ensure the highest performance?

Open ZhenGQ1030 opened this issue 2 years ago • 3 comments

I only want to use the simplest features to ensure a smooth experience

ZhenGQ1030 avatar Aug 11 '21 03:08 ZhenGQ1030

When using getHighlither, only specify the themes/languages you want to use.

octref avatar Aug 14 '21 05:08 octref

Since I've made a few of these mistakes:

  1. You should only ever call getHighlighter once. If you need more than one theme, you can use hl.loadTheme, or specify all the themes you need up front. hl.loadLanguage is the equivalent for grammars.
  2. If using codeToThemedTokens specify { includeExplanation: false } for the options. This can save a significant portion of the time that it takes to highlight since Shiki won't re-do work to try to give you an explanation for why each token has the color that it does (I'd kind of like to get rid of this option and just never do that work, I'm not sure the explanation is actually useful... have never needed it)

Gerrit0 avatar Sep 19 '21 00:09 Gerrit0

I use the explanations quite heavily, please don't remove them!

aarondfrancis avatar Aug 03 '22 21:08 aarondfrancis