From 2f74411118c35f0c9d852966af25e04b45dd3f53 Mon Sep 17 00:00:00 2001
From: Berke Güzel <wenekar1@gmail.com>
Date: Mon, 9 Feb 2026 00:47:32 +0300
Subject: formatting and more perf

---
 src/routes/+layout.svelte | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

(limited to 'src/routes/+layout.svelte')

diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 9b488bd..19a7b85 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -8,17 +8,6 @@
   let { children } = $props();
 
   onMount(() => {
-    const loadFonts = () => {
-      if (document.querySelector('link[data-app-fonts="true"]')) return;
-
-      const link = document.createElement("link");
-      link.rel = "stylesheet";
-      link.href =
-        "https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap";
-      link.setAttribute("data-app-fonts", "true");
-      document.head.appendChild(link);
-    };
-
     const loadAnalytics = () => {
       if (document.querySelector('script[data-goatcounter-script="true"]'))
         return;
@@ -32,23 +21,34 @@
       document.head.appendChild(script);
     };
 
-    const runDeferredLoads = () => {
-      loadFonts();
-      loadAnalytics();
+    const runDeferredAnalytics = () => {
+      const idleWindow = window as Window & {
+        requestIdleCallback?: (
+          callback: IdleRequestCallback,
+          options?: IdleRequestOptions,
+        ) => number;
+      };
+
+      if (typeof idleWindow.requestIdleCallback === "function") {
+        idleWindow.requestIdleCallback(loadAnalytics, { timeout: 3000 });
+        return;
+      }
+      window.setTimeout(loadAnalytics, 1500);
     };
 
     if (document.readyState === "complete") {
-      window.setTimeout(runDeferredLoads, 0);
+      runDeferredAnalytics();
       return;
     }
 
-    window.addEventListener("load", runDeferredLoads, { once: true });
-    return () => window.removeEventListener("load", runDeferredLoads);
+    window.addEventListener("load", runDeferredAnalytics, { once: true });
+    return () => window.removeEventListener("load", runDeferredAnalytics);
   });
 </script>
 
 <svelte:head>
   <link rel="icon" href={favicon} />
+  <meta name="color-scheme" content="light dark" />
 </svelte:head>
 
 <Header title="Berke Güzel" description="Super. Bad. Code." />
-- 
cgit v1.2.3

