I do have a JavaScript file, I want to include in my WordPress page, so I can execute a particular function in the onload event of the document's body element.
How do I best add my method to WordPress, so that it is executed, without breaking any other functions that might rely on the onload mechanism? I mean, I could simply redefine the body element and make it call my method, but maybe there are other plugins that need to use the same event handler.
Is there any mechanism within WordPress, so that I can append methods to the onload event (instead of redefining onload entirely)?
1) Redefine onload:
<body onload="myFunc()">
// ...
</body>
2) Versus appending:
<body onload="wp_Some_Magic_Onload_Hook()">
// ...
</body>
with
function wp_Some_Magic_Onload_Hook() {
myFunc();
otherFuncs();
// ...
}