title: What is "document.currentScript" and "ownerDocument"?
body: <p>I am learning Web Components. To grab a template, I needed to do this:</p>
  
  <pre><code>&lt;template&gt;
    &lt;div&gt;The sky is blue&lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
      var tmpl = (document.currentScript||document._currentScript).ownerDocument.querySelector('template');
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>var tmpl = document.querySelector('template');
  </code></pre>
  
  <p>I don't understand this part at all: <code>(document.currentScript||document._currentScript).ownerDocument</code></p>
  
  <p>What is <code>currentScript</code>, what is <code>ownerDocument</code>? What is the purpose? Why does it work. Note that the template code I have shown above gets pulled in via the <code>link</code> element.</p>
  
  <p>Note, this is related to this <a href="https://stackoverflow.com/questions/47419562/create-and-use-a-custom-html-component/47419631?noredirect=1#47419631">post</a> and this <a href="https://css-tricks.com/modular-future-web-components/" rel="nofollow noreferrer">article</a>. I AM just trying to understand the keywords, I don't have any particular problem in mind.</p>