From 53ea744a59e55d28ee5190e37f358afa87fe14da Mon Sep 17 00:00:00 2001 From: Timur Mashara Date: Fri, 24 Jul 2026 11:04:41 +0200 Subject: [PATCH] Guard syntax highlighting when hljs fails to load highlight.js is loaded from cdnjs, which is unreliable/blocked in some regions (notably China). When it fails to load, syntax-highlight.js threw ReferenceError: hljs is not defined on DOMContentLoaded (Sentry METABASE-COM-4W3, 10k+ events). Bail out early when hljs is missing so code blocks render unhighlighted instead of throwing. Co-Authored-By: Claude Opus 4.8 (1M context) --- js/syntax-highlight.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/syntax-highlight.js b/js/syntax-highlight.js index 6655cc6bc4..f6207749ca 100644 --- a/js/syntax-highlight.js +++ b/js/syntax-highlight.js @@ -26,6 +26,10 @@ window.addEventListener("DOMContentLoaded", () => { } }); + if (typeof hljs === "undefined") { + return; + } + hljs.configure({ ignoreUnescapedHTML: true }); hljs.highlightAll();