Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
jQuery & greasemonkey while being considerate to John's bandwidth

Here is a slight modification to Joan Piedra’s jQuery greasemonkey script that loads the jQuery library on any page you visit. This gives you the power of jQuery when using Firebug or Greasemonkey. Here is an example of its usage.

var jQueryDefinition = (function() {/*jQuery library*/});
var GM_JQ = document.createElement('script');

GM_JQ.innerHTML = '(' + jQueryDefinition.toString() + ')();';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

Here is the full script.
Here is the userscrips page.

Make sure that the jquery.user.js script is loaded before any other dependent Greasemonkey scripts.

The difference is you can put the jQuery library into the script itself. This causes the page to load faster and does not use up John Resig’s bandwidth. Unfortunately, this also means you will need to manually upgrade your greasemonkey script when the next version of jQuery comes out.

[Update] Edited the Greasemonkey script to make jQuery compatible with other js libraries.
[Update] Pointing to userscripts.org

Comments
  1. Ajit says:

    Differences noted. This should help me with my scripts more. The greasemonkey tags are very useful.

  2. Jeeba says:

    Awesome brian, just what i needed for a greasemonkey script for one webgame called ikariam, and i didnt want to use nude javascript to do it, so hard… Jquery rulez

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *