Bookmarklet: load local test script

  • 8/11/2011

Working on a data-loading application for a client, I got involved in some debugging work more complex than I was ready to handle with Firebug’s console. Access controls limited the problem script to running on the remote server, and (as I quickly tired of uploading new diagnostics) I went looking for a way to manipulate the test environment from my development computer. My answer was to create a mini-bookmarklet that would load and re-load a local test script, allowing me to update the test without needing to refresh the browser. So, in the proud tradition of bookmarklet design,

javascript:(function(){
  var script=document.createElement('script');
      script.src = encodeURI(
        '<strong>http://localhost/test-script.js</strong>?v='+Math.random()
      );
  document.body.appendChild(script);
})();```

To use this with your own tests, simply change the base path of the script (`test-script.js` in the example above) and paste a [compressed version](http://subsimple.com/bookmarklets/jsbuilder.htm) of the entire bookmarklet into your browser bar.