shiki
shiki copied to clipboard
What Settings can ensure the highest performance?
I only want to use the simplest features to ensure a smooth experience
When using getHighlither
, only specify the themes/languages you want to use.
Since I've made a few of these mistakes:
- You should only ever call
getHighlighter
once. If you need more than one theme, you can usehl.loadTheme
, or specify all the themes you need up front.hl.loadLanguage
is the equivalent for grammars. - 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)
I use the explanations quite heavily, please don't remove them!