title: Embed javascript as base64
body: <p>I'm working on a small GreaseMonkey script where I would like to embed a jQuery plugin (Markitup) so that the script is fully self contained (images + js) except for jQuery which is served from google.</p>
  
  <p>I found the site <a href="http://www.greywyvern.com/code/php/binary2base64" rel="noreferrer">http://www.greywyvern.com/code/php/binary2base64</a> which says that you can embed javascript with the href if you base64 encode the script, much like serving images as basse64 from CSS.</p>
  
  <pre><code>&lt;script type="text/javascript" href="data:text/javascript;base64,dmFyIHNjT2JqMSA9IG5ldyBzY3Jv..."&gt;&lt;/script&gt;
  </code></pre>
  
  <p>So i tried that but couldn't get it to work at all, using Firefox 3.0.5 on OS X.</p>
  
  <p>I put together a small test page to isolate the problem but couldn't get it to work at that page either.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
     &lt;head&gt;
        &lt;title&gt;Title&lt;/title&gt;
        &lt;meta charset="utf-8"&gt;
     &lt;/head&gt;
     &lt;body&gt;
        &lt;script href="data:text/javascript;base64,YWxlcnQoJ2FzYWRhc2QnKTsK"&gt;&lt;/script&gt; 
        &lt;script&gt;alert('a');&lt;/script&gt;  
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The base64 string (YWxlcnQoJ2FzYWRhc2QnKTsK) says <code>alert('asadasd');</code> so I'm supposed to get two alerts but the only one I see is the second one where the alert is located as text inside the script tag.</p>
  
  <p>Am I doing something wrong or why isn't this working, any ideas?</p>