Skip to content

Instantly share code, notes, and snippets.

@johan
Created May 22, 2011 03:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johan/985137 to your computer and use it in GitHub Desktop.
Google Closure Library loader bookmarklet
// Enumerate your own list of goog.require:s, if you want something else than TableSorter and XhrIo.
// Similarly, you can pass a callback that will get the library in its first parameter, once loaded,
// or leave it as is, if you'd rather overwrite the top window's "goog" with your own custom version.
javascript:(function(requires, callback) {
var base = 'http://closure-library.googlecode.com/svn/trunk/closure/goog/'
, iframe = document.body.appendChild(document.createElement('iframe'));
iframe.src = 'about:blank';
iframe.style.display = 'none';
iframe.contentWindow.cb = callback;
iframe.contentDocument.write('<head><script src="'+ base +'base.js"></script><script src="'+ base +
'deps.js"></script><script>'+JSON.stringify(requires)+'.forEach(goog.require);</script><script>' +
(callback ? 'cb.call(parent, goog)' : 'parent.goog = goog') + ';</script></head><body></body>');
})(['goog.ui.TableSorter','goog.net.XhrIo']/*, function optional(goog){alert(goog.net.XhrIo.send)}*/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment