--- title: Onload Event --- ## Onload Event The `onload` event is used to execute a JavaScript function immediately after a page has been loaded. ### Example: ```javascript ``` In the above example, as soon as the web page has loaded, the `myFunction` function will be called, showing the `Page finished loading` alert to the user. the `onload` event is most often used within the `` element to execute the script. If it is attached to the ``, the script will run once the web page has completely loaded all content (images, script files, CSS files, etc.). #### More Information: MDN #### Other Resources jQuery .on() Event Handler Attachment Stack Overflow: window.onload vs. document.onload