Skip to content

Commit

Permalink
Fix import URL
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaVerou committed Feb 15, 2024
1 parent f82d0c7 commit 0a4ae29
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/prism-live.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@

{
let url = document.currentScript?.src;
url = new URL(url, location);
let importURL = new URL("./prism-live.mjs", url);
importURL.search = url.search;
import(importURL).then(m => Prism.Live = m.default);
let url;
// Fall back to loading all languages
let search = "?load=css,javascript,markup";

try {
url = document.currentScript?.src ?? eval("import.meta.url");
}
catch(e) {}

if (url) {
search = new URL(url).search;
}

import("./prism-live.mjs" + search).then(m => Prism.Live = m.default);
}

0 comments on commit 0a4ae29

Please sign in to comment.