Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

v3 .refresh() is more than twice as slow when line numbers are on #1158

ibdknox opened this Issue Jan 14, 2013 · 3 comments


None yet
2 participants

ibdknox commented Jan 14, 2013

When I show an editor that was previously hidden, I call refresh (as suggested) to get everything rendered correctly again. This works wonderfully except that when line numbers are enabled the refresh takes more than twice as long, causing tab switching to stutter in my case.


marijnh commented Jan 16, 2013

I'm getting ~10ms for refreshing a small-sized editor with line numbers (as in the demos), which grows to ~30ms when the editor is full screen.

30 milliseconds isn't noticeable when switching tabs, so I assume you're seeing something else. Can you provide a minimal demo of the problem? And can you verify that you're not letting the editor itself grow very high? (For example, by giving it height: auto and putting tons of content into it.)


ibdknox commented Jan 16, 2013

I was doing it at keyboard repeat rate which I think defaults to like 40/s (25ish ms). I'm just surprised that line numbers causes that big of a jump in the time it takes to refresh. Here's a little gist that shows the difference: https://gist.github.com/4551461

Are there any gains to be made in refresh performance in general? Or some shortcut to take when hiding and showing editors frequently?


marijnh commented Jan 17, 2013

I spent a while optimizing the drawing performance just before the 3.0 release. I am not aware of any further optimization avenues, but of course there always are -- you just have to spend the time looking for them.

Line numbers (or any other kind of gutter elements) add quite a bit of complexity to the DOM structure that CodeMirror produces, which explains the difference in speed that you see (it's mostly spent in the browser's layouting algorithm).

@marijnh marijnh closed this May 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment