It finds the body tag in the document and injects the IFrame just after it along with all the JavaScript to drive it. It also provides you with a logging function with the same name as your alias (defaults to jsxray)

jsxray("Hi there");

Scans HTML for JavaScript functions

For each function it finds it inserts a call to this method which logs the function call along with the value of the function arguments.

function sum ( x, y ) {

becomes

function sum ( x, y ) {
jsxray( "sum( " + x + ", " + y + " )" );

so now any call this function and its arguments will get logged to the IFrame.

Switches to limit what you log

You can manually skip specific functions, choose to see only functions you specify, or match functions matching a specified string. ( see the switchs methods )

Provide execution counts

Provides a method to see how often your functions are being called. This can be helpful to target which functions to refactor to increase performance.

Inlines external JavaScript files

If external javascript files are referenced, they can be inlined so they'll be filtered as well.

Command line script 'jsxray'

Use the command line script 'jsxray' to save and filter local HTML files to see how things work. Think reverse engineering. :)

Save the log for later.

You can cut and paste the IFrame to a text file to analyze later by hand or munge the results with perl. Extremely helpful in moments when you have a lot of code executing and your just trying to get a handle on what's happening.

Think of this as a JavaScript namespace. All injeted JavaScript functions and variables are prefixed with this alias to avoid colliding with any code that currently exists on your page. It also is the prefix used for all the switches to toggle things on and off.

switches

Hash reference containing switches to change filtering behavior. Actually just dereferences the hash and passes it onto the 'switches' method.

abs_uri

Used to help find and filter external javascript files. It can be the absolute URL of the requested file via a webserver or the path of the file you're filtering from the command line.

Switches control the behavior of which is going to be filtered and provide the ability to uncomment debugging code on the fly.

all (bool)

Turn on filtering of all functions. This is the default behavior.

all => 1

none (bool)

Turn off filtering of functions. Helpful in combination with uncomment switch.

none => 1

uncomment ( string1, string2, ... )

Uncomment lines prefix with these strings. Helpful with injecting timing code, or more specific debugging code. You can deploy commented logging code to production and turn it on when your turn on filtering. Extremely helpful when diagnosing problems you can't reproduce in your development environment.

uncomment => "DEBUG1,DEBUG3"
uncomment => [ qw( DEBUG1 DEBUG3 ) ]

will turn this...

//DEBUG1 jsxray("Hey this is debug1");
//DEBUG2 jsxray("Hey this is debug2");
//DEBUG3 jsxray("Hey this is debug3");

into this

jsxray("Hey this is debug1");
//DEBUG2 jsxray("Hey this is debug2");
jsxray("Hey this is debug3");

anon (bool)

Include filtering of anonymous functions.

anon => 1

no_exec_count ( bool )

Don't inject code that keeps track of how many times a function was called.

WARNING THIS FUNCTIONALITY IS EXPERIMENTAL AND THE INTERFACE MAY CHANGE

Take external javascript blocks (use src attribute) and get the javascript, filter it, and inline the code. There are currently three supported methods to do this.

HTTP_GET (default)

Special string that represents using LWP::Simple to attempt to fetch external javascript. If the src attribute isn't absolute, then you'll need to pass the 'abs_uri' in when you create your instance.

File Directory

Base file path to use with the src attribute to load the javascript off disk. From a webserver, you'd probably include the web root and from the commandline, you'd use the path of the file you're filtering.

Code Reference

The arguments to the code reference are the src attribute from the javascript attribute and the code block must return the coresponding code.