I prepare a project with a simple webpage, canvas, and javascript files that run game in the canvas. I want load my code when page starts, what is best way?
- put body onload?
- startup code in body of .js file (not in function)?
- attach to window load event?
- use some jquery capability?
Thanks!
You can attach to when the page loads using jQuery like this:
If that’s the only thing you’d be using jQuery for, though, I’d probably stick with your third option you listed there.