On Mon, 23 May 2022 19:49:09 GMT, Pavel Rappo <[email protected]> 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?
Oops, I didn't even spot that. I guess that explains why some browsers were
complaining.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8751