rmurphey Adventures in JavaScript

Insert jQuery into any page using a bookmarklet

10 Dec 2007 edit

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:

{% codeblock lang:javascript %} 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);}()) {% endcodeblock %}

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.