Accessibility
You should never treat the unload event as a guaranteed callback, using it as an end-of-session signal to send analytical data and save state.
In fact, in many download situations the unload event will not fire.
Always rely on the visibilitychange event if you want to determine when a session ends, and as the last reliable time to save both app and user data, consider the state hidden.
Browsers can only be prevented from caching pages Back-Forward by the presence of a registered unload event handler (via onunload or addEventListener()).
It is therefore advisable to use the pagehide event on all modern browsers (including IE11) in order to detect page unloads.
const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload'; addEventListener(terminationEvent, (event) => { // Note: if the browser is able to cache the page, `event.persisted` // is `true`, and the state is frozen rather than terminated. }, {capture: true});
Learn more about Accessibility
On page SEO performance and page checkup.
Over 300 parameters for the deeper page analysis.
Share this Guide
Did you like it? Share it!
Web tools for modern developers. Try these one!
Over 50 generators, builders and validators to improve your SEO and web performances
Images Social
Get YouTube video thumbnails and info dataset. Retrieve YouTube video image in 9 different sizes, quality, caption, description and more.
Analytics Google Tracking script
Build your Google Campaign Url for better tracking. Add UTM parameters and track Custom Campaigns in Analytics account.
Google Server and proxy
Find out the exact date and time your web page was cached by Google’s crawler through Google Cache Status checker
Builders and generators
Generate required and most useful meta tags for your pages. Provide metadata about your website and help search engines to provide relevant content.
Generate beautiful color palette combinations for your designs. Get your combination scheme: analogous, triadic, complementary and so on.
Tester and validators
Is your web page mobile-friendly? Ready for mobile-first indexing? Test whether a page on your site is mobile-friendly or not based on Googlebot User-agent.
Test your Web Vitals metrics, score and diagnostic. Measures Google Core Web Vitals LCP, FID, CLS, TTFB, FCP, TTI, TBT and more.
Social Tester and validators
Get Facebook data and engagement count by URL. Retrieve Open Graph data, "share" count, comment count and engagement from url.