diff --git a/frontend/index.html b/frontend/index.html index 8578487..f5ffcb3 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -65,7 +65,6 @@ - Dociva — Free Online File Tools diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 2e7384d..2b62e05 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import { lazy, Suspense, useEffect } from 'react'; +import { lazy, Suspense, useEffect, useState } from 'react'; import Clarity from '@microsoft/clarity'; import { Routes, Route, useLocation } from 'react-router-dom'; import { Toaster } from 'sonner'; @@ -48,6 +48,19 @@ function LoadingFallback() { ); } +function IdleLoad({ children }: { children: React.ReactNode }) { + const [ready, setReady] = useState(false); + useEffect(() => { + if ('requestIdleCallback' in window) { + const id = requestIdleCallback(() => setReady(true)); + return () => cancelIdleCallback(id); + } + const id = setTimeout(() => setReady(true), 2000); + return () => clearTimeout(id); + }, []); + return ready ? <>{children} : null; +} + export default function App() { useDirection(); const location = useLocation(); @@ -152,7 +165,9 @@ export default function App() {