patrickgamer
patrickgamer

Reputation: 513

how to use local javascript files to test on live site using firebug (or Chrome)?

I've got some custom JS that i'm looking to deploy on a live site, but I want to test it out first.

I'm a third-party consultant to the target site managers, and am not part of their build process, so I can't deploy in their test environments. Since it's a DOM traversal library, it's pretty specific.

I was wondering if anyone knew how to get my local javascript files to auto-insert for a particular domain or host.

Thanks!

Upvotes: 5

Views: 5203

Answers (2)

Fabian Barney
Fabian Barney

Reputation: 14549

Install Greasemonkey Add-On for Firefox.

This Add-On can inject Javascript for pages with certain URLs matching a regex given in the injected JS-file.

If you want to learn how others are writing their Greasemonkey-Scripts then search for FF Add-Ons that start with "BetterXYZ" like BetterGmail, BetterFacebook, BetterGoogle ... Greasemonkey-Skripts are in fact Javascript-Files with special initial JS-Comment and a special file extension "*.user.js".

Upvotes: 2

qwertymk
qwertymk

Reputation: 35256

Why not just inject the script you're working on in firebug's console:

var script = document.createElement('script');
script.src = 'url to local file';
document.appendChild(script);

Or if you have jQuery

$.getScript('url to script file.js');

Upvotes: 4

Related Questions