Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change import strategy to use CDN delivered version of JS library
  • Loading branch information
tonypconway committed Jul 8, 2025
commit 2342bb1e1f1a1058f7633c7eea6265027439c7bb
3 changes: 0 additions & 3 deletions gh-pages/eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("./src/assets/img");
eleventyConfig.addPassthroughCopy("./src/assets/fonts");
eleventyConfig.addPassthroughCopy("./src/assets/css");
eleventyConfig.addPassthroughCopy(
{ "./node_modules/baseline-browser-mapping/dist/index.js": "/assets/js/baseline-browser-mapping/index.js" }
);
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
const mdOpts = {
html: true,
Expand Down
17 changes: 15 additions & 2 deletions gh-pages/src/supported-browsers.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,21 @@
}
</style>
<script type="module">
// Conditional equired as 11ty cannot resolve module import URLs in github pages
import { getCompatibleVersions } from 'https://cdn.jsdelivr.net/npm/baseline-browser-mapping'
let getCompatibleVersions;
try {
getCompatibleVersions = await import("https://cdn.jsdelivr.net/npm/baseline-browser-mapping")
.then(response => response.getCompatibleVersions);
} catch {
console.log("Loading baseline-browser-mapping from cdn.jsdelivr.net failed, attempting to load from unpkg.com.")
try {
getCompatibleVersions = await import("https://unpkg.com/baseline-browser-mapping")
.then(response => response.getCompatibleVersions);;
}
catch {
document.getElementById('loadingContainer').innerText = "There was an error loading baseline-browser-mapping which is required for this page to work. Please check your network connection and refresh the page.";
throw new Error("There was an error loading baseline-browser-mapping which is required for this page to work. Please check your network connection and refresh the page.")
}
}

// Declare globally useful variables
const urlParams = new URLSearchParams(window.location.search);
Expand Down