CustomLayout - how to handle window.load or document.ready?

Hello, I wish to integrate a jQuery slideshow and it seems that building the CustomLayout is the best way to do this kind of a thing. I have added jQuery script by extending default Vaadin sevlet and overriding writeAjaxPageHtmlHeader() method and created custom layout that shows up in the application correctly.

In order to show slideshow correctly, I need to invoke a slideshow library function after window has been loading completely. Apparently document ready and window load can’t be handled by the custom layout right now. This is the html file I am using from jQuery site for proof of concept.

<!DOCTYPE html>
  <style>p { color:red; }</style>
  <script src=""></script>
  $(window).load(function () {
  $("p").text("The DOM is now loaded and can be manipulated.");
  alert("Window loaded completly").


<body onLoad="alert('body has been loaded.')">

  <p>Not loaded yet.</p>



Neither of the alerts are displayed when page is loaded. Same problem with $(document).ready. Are there any possible workarounds?