From 1e3f2427d56b0a5fc286a365794ba9338caf985f Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Mon, 6 Jan 2025 08:50:31 +0100 Subject: load syntax highlight async --- assets/js/loads.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 assets/js/loads.js (limited to 'assets') diff --git a/assets/js/loads.js b/assets/js/loads.js new file mode 100644 index 0000000..71e0173 --- /dev/null +++ b/assets/js/loads.js @@ -0,0 +1,14 @@ +function load_js(url) { + let link = document.createElement("link"); + link.rel = "stylesheet"; + link.type = "text/css"; + link.href = url; + let head = document.getElementsByTagName("head")[0]; + head.appendChild(link); +} + +addEventListener("load", function () { + if (document.querySelector(".highlight .chroma")) { + load_js("/css/syntax.css"); + } +}); -- cgit v1.2.3