# Improve Scroll / Performance tradeoff

**URL:** <https://discuss.codemirror.net/t/improve-scroll-performance-tradeoff/8825>\
**Category:** v6\
**Created:** [November 19, 2024, 11:42pm UTC](https://discuss.codemirror.net/t/improve-scroll-performance-tradeoff/8825 "2024-11-19T23:42:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![awendel](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/a/7993a0/32.png) [@awendel](https://discuss.codemirror.net/u/awendel)\
**Post date:** [November 19, 2024, 11:42pm UTC](https://discuss.codemirror.net/t/improve-scroll-performance-tradeoff/8825/1 "2024-11-19T23:42:43Z")

</div>

CodeMirror seems to optimize performance via not rendering / removing lines from the DOM that are not in the viewport and instead replacing it with a “cm-gap” element that takes the height of the non visible elements.

Is there a way to customize or disable this behaviour? For example if I scroll fast on a large file there would often be frames with no lines rendered / scrollbar behaving eradically as a result. I assume the code uses IntersectionObserver behind the scenes, perhaps there would be a way to change the threshold / that it renders more lines outside of the viewport so that there are no empty frames?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [November 20, 2024, 6:47am UTC](https://discuss.codemirror.net/t/improve-scroll-performance-tradeoff/8825/2 "2024-11-20T06:47:00Z")

</div>

No, there’s no way to change this. The system’s performance is designed about the viewport being of limited size, and making it bigger would make the editor less responsive.
