Menu

The Back Button Is More Powerful Than You Think
πŸ“°

The Back Button Is More Powerful Than You Think

DEV Community: javascriptΒ·Byte CornerΒ·about 6 hours ago
#KK42le4N
#devtojavascript#devto#dev#increment#result
Reading 0:00
15s threshold

You open a website, scroll down, fill out a form, and navigate to another page.

Then you press Back.

The page appears almost instantly. Your form is still filled out. Your scroll position is exactly where you left it.

You might think the browser reloaded the page and restored some information.

But here's the interesting part: the browser may have preserved the entire page, including its JavaScript execution environment.

No HTML parsing. No component initialization. No JavaScript re-execution.

Welcome to the back/forward cache , or bfcache .

πŸ”΄ What Actually Happens When You Navigate Away?

Normally, when you navigate to a new document, the browser can discard the previous page.

Returning to it means constructing a new document, executing its scripts, and rebuilding its state.

Even with resources stored in the HTTP cache, there's still work to do.

But modern browsers have another option.

Instead of destroying the previous page, they can freeze it and preserve it in memory .

This includes:

The…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.