title: Proper way to add JavaScript include guard
body: <p>In the C programming language, there's an include guard which prevents the same header file being included twice:</p>
  
  <pre><code>#ifndef GRANDPARENT_H
  #define GRANDPARENT_H
  
  struct foo {
      int member;
  };
  
  #endif /* GRANDPARENT_H */
  </code></pre>
  
  <p>In web pages, JavaScript is often used as a header file, too. Sometimes a developer can mistakenly include the same file twice, causing bugs that are hard to debug (examples <a href="https://stackoverflow.com/a/6732163/418966">here</a>).</p>
  
  <p>The proper way to prevent multiple includes of the same file should be an include guard. But what is the proper way to add such a guard to a JavaScript file so that it works without polluting namespace, breaking other script and other unwanted behavior?</p>
  
  <hr>
  
  <p>This question is not a duplicate of <a href="https://stackoverflow.com/questions/25142935/javascript-dependencies-include-guards">that question</a>, which doesn't talk about the potential problems of using such a guard. Furthermore, it points to another library, while a lightweight, inline solution would be much more welcome. </p>