views:

93

answers:

4

I need to debug jasvascript loaded by page. Loaded page are not locally placed.

Loaded js is packed. I want to substitute it with unpacked version.

Is there any tricks or browser options to make it?

A: 

Firebug is a really good Firefox extension that lets you manipulate the DOM and you can see the changes as they happen. This will let you insert <script> tags to the page.

Just Edit the <head> piece of html through Firebug and insert the <script src="http://site.com/unpacked.js"&gt;&lt;/script&gt; somewhere in the page.

Luca Matteis
I can insert script but cannot substitute one to other.
chapluck
Well, you should then save the HTML locally and change the `<script>` tag.
Luca Matteis
)) I cannot because page includes ajax-requests to the same domain. So browser will not allow make cross-domain rquests. We can consider substitute as delete+insert. But how i can delete certain script during page loading before script execution..
chapluck
+5  A: 

It looks like Fiddler's AutoResponder tab will do this for you.

You say you want to replace the JS with the "unpacked" version--if you just want to insert line breaks so you can step through in a debugger, the Venkman debugger has a "Pretty Print" button which does that.

Annie
+1 for Fiddler AutoResponder suggestion
Daniel Trebbien
Great feature of fiddler. Thank you. I will try Venkman, it is very interesting.
chapluck
+1  A: 

It sounds like you are asking for after the application is already deployed somewhere so this might not be as helpful.

If your application already goes through a regular build script or process for debug or at least for release then you could do it there. You could leave the Javascript files as the un-minified/optimized scripts and when building for debug it just copies them over, but for release it runs them through your minifier/optimizer first before copying them over.

I know that jQuery uses a Google Compiler to package the framework up, but there are other tools that just minify the code. Also it gives you a chance to run any kind of quality checking tools (such as JSLint) on your Javascript when you already have it as part of your build process.

Other then that the AutoResponder idea from above sounds promising.

Sean Copenhaver
Thank you. I asked about already deployed application(even third party app). +1 for quality checking tools, didn`t know about it.
chapluck
+1  A: 

You could use Charles Web Debugging Proxy to map the requested JS file to a local unpacked JS file (or any other location). It costs money, but you can use the trial for 30 minute periods.

Blair McMillan