missing } after function body... even though everything is closed properly
<p>I'm trying to make a bookmarklet that first checks for jQuery on a page and loads the library if necessary, before loading my custom script. The script looks like this:</p>

<pre><code>javascript:(function() {
  function loadMyScript() {
    var my_src = document.createElement('script');
    my_src.src='url_of_my_script';
    document.body.appendChild(my_src);
  }
  function loadJQuery() {
    var otherlib = false;
    if (typeof $ === 'function') {
      otherlib = true;
    }
    function getScript(url, success) {
      var script = document.createElement('script');
      script.src = url;
      script.onload = success;
      document.body.appendChild(script);
      if (otherlib) {
        jQuery.noConflict();
      }
    }
    getScript('http://code.jquery.com/jquery-latest.min.js', loadMyScript);
  }
  if (typeof jQuery === 'undefined') {
    loadJQuery();
  } else {
    loadMyScript();
  }
})();
</code></pre>

<p>Putting this code in a bookmarket in Firefox 4, I get "missing } after function body" when I try to run it. However, running the same code in the Firebug console succeeds. Chrome yields similar results; the bookmarklet spits out "Unexpected end of input", while running the code in the console succeeds.</p>

<p>Anyone knows what's happening here?</p>

<p>(Aside: the getScript function is somewhat incomplete. I just ripped out a few things to try and solve this syntax problem)</p>
