This is an automated email from the ASF dual-hosted git repository.

reiern70 pushed a commit to branch unload-listener-1962-10.x
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit 7a02f778366356b707352c527af20ad93d2317e3
Author: reiern70 <[email protected]>
AuthorDate: Thu Nov 19 14:06:32 2026 -0500

    Stop binding an unload listener on window in the Ajax engine
    
    The Ajax engine bound a listener for the "unload" event on window to
    clear the scheduled Ajax timers when the page was left.
    
    Browsers are deprecating unload listeners. Chrome is phasing them out;
    where it has disabled them it does not run the listener and logs a
    "Permissions policy violation: unload is not allowed in this document"
    on every page that loads the Ajax engine. Where the listener still
    runs, it keeps the page out of the back/forward cache. Clearing the
    timers on unload is not needed in the first place: the timers end with
    the document that scheduled them.
    
    The listener is removed. It is not replaced by a pagehide listener:
    pagehide also fires when the page enters the back/forward cache, and
    the timers would then be gone when the user navigates back to it.
    
    An application sees no difference when the page is left. A page that
    is restored from the back/forward cache keeps its running Ajax timers,
    and pages that were barred from that cache by Wicket's listener alone
    become eligible for it. Wicket.Timer.clearAll() stays available for
    applications that want to clear the timers themselves.
    
    GitHub issue #1962
---
 .../main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js  | 7 -------
 1 file changed, 7 deletions(-)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js 
b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index c54f552d52..283b405501 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -2474,11 +2474,4 @@
        Wicket.Event.add(window, 'focusin', Wicket.Focus.focusin);
        Wicket.Event.add(window, 'focusout', Wicket.Focus.focusout);
 
-       /**
-        * Clear any scheduled Ajax timers when leaving the current page
-        */
-       Wicket.Event.add(window, "unload", function() {
-               Wicket.Timer.clearAll();
-       });
-
 })(jQuery);

Reply via email to