The problem
A reading progress bar — a thin line at the top of the page that fills as you scroll through an article — gives readers a sense of how much is left, without a plugin or a heavy library for what’s really a few lines of math.
Expected outcome
By the end of this guide you will have a progress bar that accurately fills from 0% to 100% as a reader scrolls from the top of the page to the bottom.
Requirements and costs
- Any website or blog you can add a script tag to.
- Cost: free. No dependencies.
Step-by-step implementation
- Download the starter from the link below.
- Add one line to your page:
<script src="progress-bar.js"></script>. - That’s it — the script creates the bar itself and wires up scroll/resize listeners automatically, no HTML or CSS of your own required.
A real example
At the very top of the page, the bar is 0% wide (invisible). Scrolled exactly halfway down, it’s 50% wide. Scrolled all the way to the bottom, it reaches exactly 100% — the percentage tracks scroll position against the page’s actual scrollable height, not a fixed guess.
Verification and troubleshooting
What we tested, on 5 October 2026 (record TNT-TEST-2026-10-05-032): loaded a real demo page (3000px tall) in a browser and measured the bar’s width at three real scroll positions — the very top (0%), the exact midpoint of the scrollable area (50%), and the very bottom (100%) — all three matched exactly, confirming the math is correct across the full range, not just at the endpoints.
Troubleshooting:
- The bar never reaches 100%, or overshoots past it. This can happen if your page’s content height changes after the script first runs (e.g. images loading late and pushing the page taller) — the script already recalculates on resize, but a content-height change that isn’t a resize event won’t trigger it; call the update function again after your content finishes loading if needed.
- You want it only on long-form posts, not every page. Only include the script tag on the templates/pages where you want it — it has no effect until added.
- The bar’s color clashes with your site. It’s one CSS property (
background) in the script — change it to match your site’s palette.
Limitations and alternatives
This tracks scroll position against the whole page, which is accurate for a page that’s entirely one article, but less meaningful on a page with a lot of content before or after the article itself (a long header, a comments section). For that layout, measure against the article element’s own bounds instead of the full document.
Free resources
The download contains the script and a working demo.
Download the reading progress bar (ZIP, 1 KB)
Is there a paid version?
Not applicable. There’s no meaningful paid version of a progress bar — this is the complete method.