title: How do I load an external JS library in Svelte/Sapper?
body: <p>I have been trying to load the ace editor (<a href="https://ace.c9.io/" rel="noreferrer">https://ace.c9.io/</a>) into my Sapper application. I had success loading it in the script tag when I loaded it in a Sapper route, but when I am trying to do the same in a Svelte component which is again rendered by a route I get the error:</p>
  
  <p><em>ace is not defined</em></p>
  
  <p>This is the code I have, which is working fine if it is a Sapper route:</p>
  
  <pre><code>&lt;div id="editor"&gt; def main():
      return sum(range(1,100))
  &lt;/div&gt;
  
      &lt;script src="https://pagecdn.io/lib/ace/1.4.6/ace.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
  
      &lt;script&gt;
            var editor = ace.edit("editor");
            editor.setTheme("ace/theme/monokai");
            editor.session.setMode("ace/mode/python");
            editor.resize()
      &lt;/script&gt;
  </code></pre>