It's now possible to detect and execute JavaScript code after the page is fully ready, i.e. after all resources have been loaded and there are no pending HTTP requests or promises:

require(['xwiki-page-ready'], function(pageReady) {
  pageReady.afterPageReady(() => {
    console.log('Page is ready!');
  });
});

This is currently used by the client-side PDF export to know when the page is ready for print and by the automated functional tests to know when to start interacting with the page (simulating user actions). See the Page Ready module documentation for more information.

Tags:
   

Get Connected