title: When are javascript functions executed
body: <p>I think it has to be an easy question but I have been searching around and have not found the answer anywhere.</p>
  
  <p>The think is that I have an html page with some scripts (in the body) like this one:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;grf();&lt;/script&gt;
  </code></pre>
  
  <p>The grf() function is defined in an external .js file.
  The question is: is this function executed once the browser has loaded the page AND all of its external js files? Or it can be the case that the function is executed before the .js files are loaded? And if so, how can I prevent this?</p>