Skip to content

Commit cd1939b

Browse files
committed
perf(tokenizer/prism): ensure async deps loading
As far as I know programmatically created scripts are always asynchronous by default. Anyhow explicitly setting the async attribute to ensure that the scripts are loaded and executed without blocking the parsing of the HTML document. Related: #39
1 parent 668a297 commit cd1939b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/tokenizer/prism.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ export async function loadPrismLanguage({ baseUrl, language }) {
298298
if (langData.has(lang)) return resolve();
299299
const script = document.createElement('script');
300300
script.src = `${baseUrl}/components/prism-${lang}.min.js`;
301+
script.async = true;
301302
script.onload = () => {
302303
document.head.removeChild(script);
303304
langData.add(lang);
@@ -322,6 +323,7 @@ export function loadPrismCore(baseUrl) {
322323
return new Promise((resolve, reject) => {
323324
const script = document.createElement('script');
324325
script.src = `${baseUrl}/components/prism-core.min.js`;
326+
script.async = true;
325327
script.onload = resolve;
326328
script.onerror = reject;
327329
document.head.appendChild(script);

0 commit comments

Comments
 (0)