Skip highlight.js if not needed on the page
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Highlight.JS: https://highlightjs.org/
|
||||
|
||||
async function initializeHighlightJS() {
|
||||
|
||||
const languageRE = /\blanguage-([a-zA-Z0-9_\-]+)\b/gi;
|
||||
const noLanguageRE = /\bno-language\b/gi;
|
||||
const languages = [
|
||||
@@ -57,6 +58,12 @@ async function initializeHighlightJS() {
|
||||
"xml",
|
||||
"yaml",
|
||||
];
|
||||
const selector = "code.block[class*=\"language\"]";
|
||||
|
||||
if (document.querySelectorAll(selector).length == 0) {
|
||||
console.log("highlight.JS: Skipping, as it is not needed here.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("highlight.JS: Loading...");
|
||||
let highlightJS = await import("./highlightjs/highlight.mjs");
|
||||
|
||||
Reference in New Issue
Block a user