diff --git a/src/js/events/components.js b/src/js/events/components.js index 79e3a8a..582af8d 100644 --- a/src/js/events/components.js +++ b/src/js/events/components.js @@ -12,7 +12,19 @@ class HighlightedCode extends ElemJS { this.element.appendChild(child) } } - lazyLoad("./static/hljs.js").then(hljs => hljs.highlightBlock(this.element)) + if (this.element.textContent.length > 80) { + /* + no need to highlight very short code blocks: + - content inside might not be code, some users still use code blocks + for plaintext quotes + - language detection will almost certainly be incorrect + - even if it's code and the language is detected, the user will + be able to mentally format small amounts of code themselves + + feel free to change the threshold number + */ + lazyLoad("./static/hljs.js").then(hljs => hljs.highlightBlock(this.element)) + } } }