We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This will prevent the UI from freezing when highlighting a very big code block.
As suggested in highlight.js usage examples:
You can run highlighting inside a web worker to avoid freezing the browser window while dealing with very big chunks of code. In your main script: addEventListener('load', () => { const code = document.querySelector('#code'); const worker = new Worker('worker.js'); worker.onmessage = (event) => { code.innerHTML = event.data; } worker.postMessage(code.textContent); }); In worker.js: onmessage = (event) => { importScripts('<path>/highlight.min.js'); const result = self.hljs.highlightAuto(event.data); postMessage(result.value); };
You can run highlighting inside a web worker to avoid freezing the browser window while dealing with very big chunks of code.
In your main script:
addEventListener('load', () => { const code = document.querySelector('#code'); const worker = new Worker('worker.js'); worker.onmessage = (event) => { code.innerHTML = event.data; } worker.postMessage(code.textContent); });
In worker.js:
onmessage = (event) => { importScripts('<path>/highlight.min.js'); const result = self.hljs.highlightAuto(event.data); postMessage(result.value); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This will prevent the UI from freezing when highlighting a very big code block.
As suggested in highlight.js usage examples:
The text was updated successfully, but these errors were encountered: