Search code examples
jquerygreasemonkey

Replace jQuery version of a page with Greasemonkey


How can i replace jquery version of a page with greasemonkey?

Im trying to test a site with a newer version of jquery but i dont have a dev enviroment.


Solution

  • I know you're asking about jQuery and Greasemonkey for doing this, but let me off a completely different alternative, Fiddler.

    If you're testing a site out with a new version of jQuery and you actually want to test any breaking changes, etc...you want to test the site as it will be, whereas a JavaScript (greasemonkey)-based after-the-fact replacement isn't an accurate simulation.

    With fiddler you can replace the jQuery file that the browser requests (without the browser knowing). This way you're actually testing it completely, you're straight up dropping the new version in the page, no in-page JS tricks which may not be at all accurate to get there (handlers already hooked up, load order, etc.)

    Eric Law (creator of Fiddler) has an excellent blog post on how to do exactly this:

    Swapping out JQuery with Fiddler

    The post was written for swapping out the minified version with the full version (also handy!) or a newer version for debugging, be sure to note both uses...they're both very useful in saving some debug/testing time.