// load jQuery only if it's not yet loaded if (typeof jQuery == 'undefined') { // and inject it into the page var jQ = document.createElement('script'); jQ.type = 'text/javascript'; jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; // run the bookmarkletcode after jQ has been loaded jQ.onload=runBookmarklet; document.body.appendChild(jQ); } else { runBookmarklet(); } function runBookmarklet() { // the magic happens here alert("whoohoo, injection!"); } // when done, minify with John Gruber's Bookmarklet-Builder. It's old, but works like a charm // http://daringfireball.net/2007/03/javascript_bookmarklet_builder