From 0482a43ac70a80ff89a12d5a676ed80002bdda1c Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sat, 6 Jun 2026 16:51:07 +0200 Subject: [PATCH] refactor: replace DOMContentLoaded with onReady utility --- static/sort_filter.ts | 4 +++- static/theme.ts | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/static/sort_filter.ts b/static/sort_filter.ts index 0183a0c..03f777d 100644 --- a/static/sort_filter.ts +++ b/static/sort_filter.ts @@ -1,3 +1,5 @@ +import { onReady } from "./utils"; + const initSortFilter = (): void => { const sortSelect = document.getElementById("sort-select") as HTMLSelectElement | null; const orderSelect = document.getElementById("order-select") as HTMLSelectElement | null; @@ -21,4 +23,4 @@ const initSortFilter = (): void => { }); }; -document.addEventListener("DOMContentLoaded", initSortFilter); +onReady(initSortFilter); diff --git a/static/theme.ts b/static/theme.ts index 104937c..e654f74 100644 --- a/static/theme.ts +++ b/static/theme.ts @@ -1,3 +1,5 @@ +import { onReady } from "./utils"; + type Theme = "light" | "dark"; const colorSchemeQuery = window.matchMedia?.("(prefers-color-scheme: dark)") ?? null; @@ -17,8 +19,4 @@ const initTheme = (): void => { colorSchemeQuery?.addEventListener("change", () => applyTheme(getPreferredTheme())); }; -if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", initTheme); -} else { - initTheme(); -} +onReady(initTheme);