Passing languages list into CodeMirror plugin causes extreme lag
#943
-
|
Title. When I input the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
|
Edit: this analysis was incorrect... You're not doing anything wrong, and this is a known pattern, not just you. Here's what's almost certainly going on, and what to do about it. Why it lags: the docs do show Fix that keeps your language selector: don't pass the whole import { javascript } from '@codemirror/lang-javascript'
import { python } from '@codemirror/lang-python'
// ...only the languages you actually need
codeMirrorPlugin({
codeBlockLanguages: [
{ name: 'JavaScript', alias: ['js', 'javascript'] },
{ name: 'Python', alias: ['py', 'python'] },
{ name: 'CSS', alias: ['css'] },
// etc - just the ones your users actually use
],
})This still gives you a proper language-selector dropdown - just scoped to the handful of languages you actually support instead of all ~200 CodeMirror knows about. Most people don't need more than 10-20 in practice. If you trim it down and the lag is still there even with a short list, that points to the broader, already tracked typing performance issue (#839) rather than this specific list - worth adding a comment there with your repro details either way, since the maintainers were specifically asking to understand the real world severity of it. |
Beta Was this translation helpful? Give feedback.
@MrDiamondDog from what you're saying, most likely you're refreshing the entire component setup on each keystroke. You can probably reproduce this in stackblitz/sandbox.