Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ const config: Config = {
// Self-hosted, cookieless Umami analytics. GitHub Pages cannot reverse-proxy the
// script under this origin the way the nginx-served apps do, so it loads directly.
// data-domains keeps local dev and the github.io mirror out of the stats.
// static/stats-loader.js adds the tracker only after the page has loaded, so a slow or
// hanging Umami can't hold up the page's load event.
scripts: [
{
src: 'https://analytics.codeuctivity.cloud/script.js',
src: '/stats-loader.js',
defer: true,
'data-website-id': 'dc19b213-947c-477b-8eb5-4a5816542c18',
'data-domains': 'codeuctivity.cloud',
Expand Down
16 changes: 16 additions & 0 deletions static/stats-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Adds the Umami tracker only after the page has finished loading. A script added before
// `load` holds the load event (and the tab spinner) until it arrives, so when Umami hung
// on 2026-11-14 pages never finished loading.
(() => {
const config = document.currentScript?.dataset;
if (!config?.websiteId) return;
const inject = () => {
const script = document.createElement('script');
script.src = 'https://analytics.codeuctivity.cloud/script.js';
script.dataset.websiteId = config.websiteId;
if (config.domains) script.dataset.domains = config.domains;
document.head.appendChild(script);
};
if (document.readyState === 'complete') inject();
else window.addEventListener('load', inject, {once: true});
})();
Loading