I'm working on a JavaScript library which needs to give the user the ability to run some code on load. Of course, I'm familiar with window.onload
, and things like $(function() {});
with jQuery. But I don't want to be dependent on another library, and I want this particular function (along with the rest of the lib, of course) to be cross-browser.
So is there an accepted way of attaching to the onload
function without overriding another library's load functionality (or having mine overwritten if they include another lib after mine)?