Load javascript after 5 seconds after page has loaded?

html, javascript

Solution

window.addEventListener("load", function () {
    animation();
    setTimeout(otherOperation, 5000);
}, false);

function animation() {}
function otherOperation() {}

maybe you can use code like this

Problem

I have tried the following: ``` <body id="myBody" onload = "setTimeout('a()', 5000)" / > ``` Is this the correct method? The reason why I want to do this is because I have my entire website animating in (such as fade ins) on page load. Having my javascript only makes the animation unsmooth. Any feedback appreciated.

Original source