title: How do I use Firebase in an external Javascript file
body: <p>This is probably a very simple issue, but I've been trying to use Firebase in an external javascript file that is being used with an HTML file and can't get it to work properly. I am planning to use this file for many other similar pages, so I'd rather keep it in an external document. Specifically, my code is:</p>
  
  <pre><code>$(function() {
  
  var head= document.getElementsByTagName('head')[0];
  var script= document.createElement('script');
  script.src= 'https://cdn.firebase.com/v0/firebase.js';
  head.appendChild(script);
  
  var Database = new Firebase('https://myfirebase.firebaseIO.com/');
  ...
  </code></pre>
  
  <p>but when I try to run it, it says that the Firebase object/keyword is undefined. I know that the script is being correctly appended to the HTML page because I've checked the HTML on the page after running the code. </p>
  
  <p>I have also read somewhere that you might need to have a personal server to run Firebase, but frankly I don't really know what that means - in any case, I use Mac OSX and run all of my HTML and Javascript in Chrome.</p>
  
  <p>Thank you very much!</p>