---
title: "`unload` event listener (lint/unload-listener)"
description: "lint/unload-listener: An `unload` handler makes the page ineligible for the back/forward cache in most browsers, so every back navigation reloads the page…"
canonical: https://void-design.vercel.app/rules/lint/unload-listener
lastModified: 2026-09-16
---

# `unload` event listener

`lint/unload-listener` · severity **warn** · category Lint · detected by `void lint` and `void audit`

## Why it matters

An `unload` handler makes the page ineligible for the back/forward cache in most browsers, so every back navigation reloads the page instead of restoring it instantly. The event is also unreliable on mobile.

## How to fix it

Use `pagehide` (or `visibilitychange` for analytics beacons). Only add `beforeunload` while there are unsaved changes.

## Example

```ts
addEventListener('pagehide', () => navigator.sendBeacon('/log', data))
```

## References

- https://web.dev/articles/bfcache#never-use-the-unload-event

## More lint rules

`void lint` reports 67 rules in this category. Static source checks with no browser: Tailwind v4 silent failures, Next.js 16 API traps, React render-body bugs, accessibility markup, SEO files and motion hygiene.

- `webgl-in-map` WebGL canvas rendered inside `.map()` — [lint/webgl-in-map](https://void-design.vercel.app/rules/lint/webgl-in-map)
- `raf-without-cancel` `requestAnimationFrame` loop in an effect without `cancelAnimationFrame` — [lint/raf-without-cancel](https://void-design.vercel.app/rules/lint/raf-without-cancel)
- `listener-without-cleanup` Event listener or interval added in an effect without cleanup — [lint/listener-without-cleanup](https://void-design.vercel.app/rules/lint/listener-without-cleanup)
- `scroll-listener-nonpassive` `wheel` / `touchstart` / `touchmove` listener without `{ passive: true }` — [lint/scroll-listener-nonpassive](https://void-design.vercel.app/rules/lint/scroll-listener-nonpassive)
- `useeffect-fetch` Page fetches its data in `useEffect` — [lint/useeffect-fetch](https://void-design.vercel.app/rules/lint/useeffect-fetch)
- `div-button` Clickable `<div>`/`<span>` without button semantics — [lint/div-button](https://void-design.vercel.app/rules/lint/div-button)
- `dangerously-set-jsonld-unescaped` JSON-LD injected with `JSON.stringify` without escaping `<` — [lint/dangerously-set-jsonld-unescaped](https://void-design.vercel.app/rules/lint/dangerously-set-jsonld-unescaped)
- `transition-all` `transition: all` / `transition-all` — [lint/transition-all](https://void-design.vercel.app/rules/lint/transition-all)

Detected by `void lint` and `void audit`. Explain it in a terminal: `void rules lint/unload-listener`
