I’m working on a web application where I need to collect performance data from users’ browsers. This includes things like how long it takes for pages to load, DNS lookup times, and other timing information. I’ve managed to get this working perfectly in Firefox and Chrome using the standard browser APIs. However, I’m running into issues with Safari and Opera browsers. These browsers seem to handle performance tracking differently. Has anyone found a reliable way to gather page load metrics in Safari and Opera? I’m open to alternative approaches or polyfills that might work across these browsers. Any code examples or libraries you’d recommend would be really helpful.
Been fighting this for months across different projects. Safari’s problem isn’t just missing APIs - it throttles performance data collection in weird scenarios. I built a custom timing solution using performance.now() with manual markers at document start, DOMContentLoaded, and window.onload. Opera’s inconsistency comes from how it handles resource timing entries - they’re often delayed or incomplete. I set up polling that checks for performance entries every 100ms until I get complete data or timeout. Safari Mobile acts differently than desktop Safari, so you need browser detection for the variants. Run multiple measurement strategies at once and use the most reliable data from whatever works.
I’ve hit this exact problem in production. Safari blocks the Navigation Timing API when users have cross-site tracking prevention on - you’ll get zero values for performance.timing entries. My fix was using performance.mark() and performance.measure() as backups when the standard timing API craps out. Opera supports the full Performance API but sometimes performance.getEntriesByType(‘navigation’) returns empty arrays. Wrap your performance collection in try-catch blocks and use Date.now() timestamps at key points as your final fallback. Works reliably on both browsers. The trick isn’t just checking if the APIs exist - you need to catch when they’re there but spitting out garbage data.
safari’s performance api can be wonky - check if window.performance.getEntriesByType exists before using it. opera handles most standard apis fine, but older versions might need fallbacks. if the full api doesn’t work, try performance.now() for basic timing.