Reload the current page
Load the current document again.
function reload() { location.reload(); }
Usage
reload(); // e.g. the page loads again; browsers may restore form fields and scroll position
Know the limits
- Reloading discards in-memory state. Prefer updating the part of the page that changed.
- The original’s alternative, location.href = location.href, does not reload when the URL has a fragment: it only scrolls.
The function above is the code the usage lines run. It does not validate its arguments; add checks where it receives untrusted input.
Source & maintenance
Based on Reload the current page from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.
Reviewed, not executed, because it navigates. Original MDX retained as inert source evidence.
Maintained by Oveyon. Source commit: 14b481cf60df. Read the license.
Keep exploring
- Check if a given DOMRect is contained within another DOMRect — True when the target lies inside the container or on its edges.
- Check if two DOMRects intersect — Two rects intersect when they meet on both axes.
- Compare two DOMRects for size and position match — Compare x, y, width and height exactly.