Friday, March 14, 2014

How To Load jQuery Into Any Page With A Bookmarklet

Sometimes while surfing the web I run across a page I want to manipulate or parse.
jQuery + your browser’s developer tools makes it really easy to manipulate pages on the fly. More often than not jQuery is already included on a page and we’re set. But what if you’re at the ancientSpace Jam website and jQuery isn’t available?
You can easily load it by opening the JavaScript console in the developer tools panel and entering these lines of code:
var script = document.createElement("script");
script.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.head.appendChild(script);
I’ve wanted to do this often enough that I created a bookmarklet to do it for me. A bookmarklet is a bookmark that executes JavaScript on a page instead of directing you to a new URL.
This link will load jQuery into a page if it isn’t already there: jQuerify!.
Clicking on it will execute the code, so you’ll want to save it as a bookmark by dragging it into your bookmark bar, or right clicking and saving it as a bookmark, depending on your browser. Having it in your bookmark bar makes executing the code as easy as pressing a button.
If you’re interested in creating your own bookmarklet, I’ve created a JSBin that makes it quite easy.Check it out here.
via:http://todaymade.com/blog/jquery-bookmarklet/

No comments:

Post a Comment