history.replaceState is slow on large pages




Document Navigation
2 years ago
a year ago


(Reporter: alex, Unassigned)


40 Branch

Firefox Tracking Flags

(Not tracked)




2 years ago
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36

Steps to reproduce:

Open a website that adds more and more content with ajax as you scroll (not related to scrolling, I just thought it makes the case more obvious).

As an example, DuckDuckGo search (https://duckduckgo.com/?q=firefox) or google image search (https://www.google.ru/search?q=cat&newwindow=1&biw=1215&bih=623&source=lnms&tbm=isch&sa=X). We're developing a similar website, only it's supposed to change urls as user scrolls the page.

So turns out that the more content is there on website, the more time `history.replaceState` takes to change url. I used this snippet in the debugger to measure it:

    history.replaceState(null, 'test', window.location.href+'x');

In the duckduckgo example above on my computer it takes 8ms initially and goes to 12ms if you scroll to the bottom. On google page linked it went from 7ms to 25ms at the bottom. In my local experiments with a huge page it went all the way to 80ms.

The large delay happens only if url actually changes (that's why I'm adding "x" in the snippet above).

Actual results:

The more content is on the page, the longer it takes to change URL using `history.replaceState()`. Which presents a performance issue on large websites.

Expected results:

I'd expect it to take constant time, that does not depend on a page content.

Comment 1

2 years ago
forgot to mention, I tested it with Firefox 40 (not on Chromium which the auto-generated part of the ticket might suggest :)


2 years ago
Component: Untriaged → Bookmarks & History
Component: Bookmarks & History → Document Navigation
Product: Firefox → Core
You need to log in before you can comment on or make changes to this bug.