Skip to content

Commit

Permalink
Improved test page performance for Chromium (#2020)
Browse files Browse the repository at this point in the history
This improves the performance of the test page for large chunks of text in Chromium-based browsers.
  • Loading branch information
RunDevelopment authored Aug 29, 2019
1 parent a7cf56b commit 3509f3e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,22 @@ <h2>Test drive</h2>

<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) {
Expand Down

0 comments on commit 3509f3e

Please sign in to comment.