Adventures in JavaScript Development

Insert jQuery Into Any Page Using a Bookmarklet

| Comments

Ever wish you could use jQuery on a page at the drop of a hat, without having access to the page itself? Well I’ll be damned, you can.

(This is one of those things that in hindsight seems so painfully obvious that I’m almost embarrassed to admit that it never occurred to me, but admit it I will.)

For those working with jQuery 1.2.1, here is an updated Insert jQuery 1.2.1 bookmarket, and here is the code for the bookmarklet in its entirety:

1
javascript:void(function(){var s=document.createElement('script'); s.src='http://code.jquery.com/jquery-1.2.1.js'; document.getElementsByTagName('head')[0].appendChild(s);}())

I came across this in a recent post at Morethanseven, but the Simon Willison post is from August, so this is probably a bit of old news. I’m still excited though.

Comments