Why Reading Progress Bars Increase Content Engagement
Long-form technical articles, case studies, and documentation guides often lose readers when users cannot tell how much content remains. Top scroll progress bars provide instant visual feedback on reading depth, reducing bounce rates and increasing average time on page by up to 22%.
Calculating Scroll Percentage Efficiently
To compute exact page scroll completion without triggering layout thrashing:
function updateProgress() {
const scrollTop = window.scrollY;
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
const progress = docHeight > 0 ? (scrollTop / docHeight) * 100 : 0;
progressBar.style.width = `${progress}%`;
}
window.addEventListener('scroll', updateProgress, { passive: true });
Modern CSS Linear Gradient Animation
The progress line utilizes a 90-degree linear-gradient with box-shadow glow, producing an electric neon line that highlights progress across dark and light backgrounds alike.