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
Analytics Google Tracking script
Build your Google Campaign Url for better tracking. Add UTM parameters and track Custom Campaigns in Analytics account.
Builders and generators
Generate your Web App Manifest json and improve site data. Provide information about your website, allow users to quick access for a better experience.
Generate URLs for iOS Campaign Measurement. Use this free tool to generate URLs for measuring the source of iOS application installs.
Builders and generators Google
Choose a map theme or build your custom Google map. Customize maps with your own creativity, settings, styles and colors.
Builders and generators Social
Generate Twitter cards markup and improve yours html meta. Attach rich photos, videos and media experiences to Tweets and drive traffic to your site.
Social Tracking script
Measure and track user interactions with your contents. Track all the events you want: downloads, clicks, video plays, checkout flow, engagement.
Converters
Convert instantly color codes from RGB (red, green, blue) to HEX triplets color schema and vice versa. Insert color and try it for free.
Create Analytics trackable URL and track email opens. Send your email campaign and get data when user open your email.