diff --git a/src/components/BottomBar.js b/src/components/BottomBar.js index 5c9a8bd..aec1368 100644 --- a/src/components/BottomBar.js +++ b/src/components/BottomBar.js @@ -1,9 +1,17 @@ +import PageLoadTime from "./PageLoadTime"; + const BottomBar = () => { return (
Powered by React.
+© LibreBun 2023-2025
Page:
Forgejo
- +Lemmy
diff --git a/src/components/PageLoadTime.js b/src/components/PageLoadTime.js new file mode 100644 index 0000000..d2e3753 --- /dev/null +++ b/src/components/PageLoadTime.js @@ -0,0 +1,33 @@ +import { useEffect, useState } from "react"; + +const PageLoadTime = ({ className }) => { + const [loadTime, setLoadTime] = useState(null); + + useEffect(() => { + const onLoad = () => { + const timing = performance.timing; + const pageLoadTime = timing.loadEventEnd - timing.navigationStart; + + if (pageLoadTime > 0) { + setLoadTime(pageLoadTime); + } else { + setLoadTime(performance.now()); + } + }; + + if (document.readyState === "complete") { + onLoad(); + } else { + window.addEventListener("load", onLoad); + return () => window.removeEventListener("load", onLoad); + } + }, []); + + return ( + + {loadTime !== null ? `${loadTime.toFixed(0)} ms` : ""} + + ); +}; + +export default PageLoadTime; \ No newline at end of file diff --git a/src/components/Stream.js b/src/components/Stream.js index 61c5c55..3889772 100644 --- a/src/components/Stream.js +++ b/src/components/Stream.js @@ -7,7 +7,7 @@ const StreamPage = () => {