RFR: JDK-8286832: JavaDoc pages call browser history API too often
Pavel Rappo
prappo at openjdk.java.net
Mon May 23 19:52:42 UTC 2022
On Tue, 17 May 2022 13:48:25 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:
> This is a small but important fix in our browser script that ensures that the `history.replaceState()` function is not called repeatedly during scrolling. The existing code makes sure the function is called no more often then every 100 milliseconds, but that is still unnecessarily often and enough to make Firefox complain and degrade the scrolling performance on Chrome on Android.
>
> The new code does not call the function until after the user has stopped scrolling. This is what we want and fixes all the above mentioned problems.
>
> I have tested the new code thoroughly on Firefox and Chrome on Mac OS and Linux, Safari on Mac OS and iOS as well as Chrome on Android.
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js line 142:
> 140: contentDiv.addEventListener("scroll", function(e) {
> 141: var timeoutID;
> 142: if (!timeoutID) {
I don't understand JavaScript, so could you briefly explain how that _used_ to work? It reads like we declare a variable and then immediately check it for being set?
-------------
PR: https://git.openjdk.java.net/jdk/pull/8751
More information about the javadoc-dev
mailing list