Commit 3509f3e5c6caf9b5805f99db6326dbc0ac34e2ef

Michael Schmidt 2019-08-29T16:37:13

Improved test page performance for Chromium (#2020) This improves the performance of the test page for large chunks of text in Chromium-based browsers.

diff --git a/test.html b/test.html
index d0c4771..8180554 100644
--- a/test.html
+++ b/test.html
@@ -134,9 +134,22 @@ pre.show-tokens {
 
 <script>
 (function() {
-var form = $('form'), code = $('code', form),
-    languages = components.languages,
-    highlightCode = function() { Prism.highlightElement(code); };
+/** @type {HTMLFormElement} */
+var form = $('form');
+/** @type {HTMLElement} */
+var code = $('code', form);
+var languages = components.languages;
+
+function highlightCode() {
+	var newCode = document.createElement('code');
+	newCode.textContent = code.textContent;
+	newCode.className = code.className;
+
+	Prism.highlightElement(newCode);
+
+	code.parentElement.replaceChild(newCode, code);
+	code = newCode;
+};
 
 
 function updateHashLanguage(lang) {