Create a gist now

Instantly share code, notes, and snippets.

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