← Back to Edu
Web Tips
Practical web development tips and Q&A.
How to check when a webpage was opened in your browser
Using the (deprecated) PerformanceTiming API:
console.log("The page was opened at:", new Date(performance.timing.navigationStart));
The modern approach uses PerformanceNavigationTiming:
const [navEntry] = performance.getEntriesByType("navigation");
if (navEntry) {
console.log("The page was opened at:", new Date(navEntry.startTime + performance.timeOrigin));
}