title: Javascript - Use onload event , or not
body: <p>I'm coding a script that will be used on several websites as a plugin. I have to use only Javascript, no framework. I'm asking myself, what is the best way to load my script without causing any trouble with other scripts or frameworks that can be loaded on these websites.
  I thought to do a global function where i call the functions I want to use, and I put this function on the window.load event, like this :</p>
  
  <pre><code>&lt;script&gt;
      var global = function(){
      object.domain.function1();
      object.domain.function2(param1, param2);
      object.domain.function3(1);
  }
  (function(){
      if(document.addEventListener){
          document.addEventListener('load',global, false);
      }
      if(document.attachEvent){
          document.attachEvent('onload',global);
      }
  })();
  &lt;/script&gt;
  </code></pre>
  
  <p>Or simply :</p>
  
  <pre><code>&lt;script&gt;
      object.domain.function1();
      object.domain.function2(param1, param2);
      object.domain.function3(1);
  &lt;/script&gt;
  </code></pre>
  
  <p>Of course, I need some elements are loaded on my page.
  Thanks in advance.</p>