Extension to Minify Content in Fiddler

1,043 views
Skip to first unread message

yegger

unread,
May 8, 2009, 5:08:07 PM5/8/09
to Fiddler
Hi All,

Is there an extension to Fiddler to do minification? I'd like to check
the difference in page sizes without changing the server config?

I did a search, but did not find anything.


Regards,
John

TonyMu

unread,
May 8, 2009, 5:29:14 PM5/8/09
to Fiddler
Would seeing the size of the Response Body meet your needs? I don't
have a default install (I've loaded the neXpert add-in) to tell if
that's turned on out-of-the-box, but Body is one of the columns
displayed in the UI when I run Fiddler 2.2.2.0.

yegger

unread,
May 8, 2009, 5:38:38 PM5/8/09
to Fiddler
Thanks Tony,

Yes, I'd like to see the size of the response body. which Fiddler does
show me.

However I'd like Fiddler to actual minify css and javascript, show me
the original size and the new size.

This would allow me to do pageweight analysis then and also do some
browser performance analysis with a browser client plugin.

Regards,
John

TonyMu

unread,
May 8, 2009, 6:26:09 PM5/8/09
to Fiddler
ahhh, ok, sorry I didn't recognize the term "minify" but after doing
some Kumo searching I translated to term into something I do
recognize: you want to see the difference in size between HTTP
compressed content and non-compressed content.

I see where that type of data is exposed through the default
inspector. If it's exposed through Fiddler's object model we'll get
you the data (because I want it too :-)
> > > John- Hide quoted text -
>
> - Show quoted text -

TonyMu

unread,
May 12, 2009, 3:28:14 PM5/12/09
to Fiddler
add the following to your CustomRules.js and you should see the
behavior you're after...

//start ResponseTiming
// Description:
// This FiddlerScript sample logs values from all currently
// selected sessions to a file in Tab Separated Value (TSV)
// format.
// Notes:
// * The log file will be created in the Capture folder and
// has the name: ResponseTiming.log
// * Subsequent executions of this script will overwrite the
// the previous ResponseTiming.log file.
// * This script will run against any highlighted Fiddler
// sessions, whether Capture is enabled or not, but it will
// not automatically refresh the log if new Sessions are
// captured.
// Version History:
// * 2009-05-09: initial release
// Usage:
// 1. launch Fiddler
// 2. navigate to Rules > Customize Rules...
// 3. add the following text at the top of the file:
// import System.IO;
// 4. go to very end of file
// 5. paste all lines between 'start ResponseTiming' and
// 'end ResponseTiming' above the last close curly brace: }
// 6. choose Yes when prompted to Save Changes
// 7. navigate to Tools > Log ResponseTimes for Selected
Sessions
// 8. open the .log file in %USERPROFILE%\Documents
\Fiddler2\Capture
// in Microsoft Excel or other editor of choice.
//
public static ToolsAction("Log ResponseTimes for Selected Sessions")

function DoLogSessions(oSessions: Fiddler.Session[])
{
if (null == oSessions || oSessions.Length < 1)
{
MessageBox.Show("Please select some sessions first!");
return;
}
var strLogFile = CONFIG.GetPath("Captures") + "ResponseTimes.log";
var swLogFile:StreamWriter = null;

try
{
swLogFile = File.CreateText(strLogFile);
//set the headings for the log file
swLogFile.Write("method\t");
swLogFile.Write("protocol\t");
swLogFile.Write("host\t");
swLogFile.Write("ServerPort\t");
swLogFile.Write("uri-stem\t");
swLogFile.Write("Status\t");
swLogFile.Write("ResponseBodySize\t");
swLogFile.Write("ServerIP\t");
swLogFile.Write("ProcessInfo\t");
swLogFile.Write("ClientPort\t");
swLogFile.Write("Proxy\t");
swLogFile.Write("RequestStart\t");
swLogFile.Write("ResponseFinish\t");
swLogFile.Write("TotalMilliseconds\t");
swLogFile.Write("CompressNone\t");
swLogFile.Write("CompressDeflate\t");
swLogFile.WriteLine("CompressGZip");
for (var x = 0; x < oSessions.Length; x++)
{
swLogFile.Write(oSessions[x].oRequest.headers.HTTPMethod + "\t");
swLogFile.Write((oSessions[x].oRequest.headers.UriScheme).ToUpper
() + "\t");
swLogFile.Write(oSessions[x].host + "\t");
swLogFile.Write(oSessions[x].port + "\t");
swLogFile.Write(oSessions[x].oRequest.headers.RequestPath + "\t");
swLogFile.Write(oSessions[x].responseCode + "\t");
swLogFile.Write(oSessions[x].responseBodyBytes.Length + "\t");
swLogFile.Write(oSessions[x].oFlags["x-hostIP"] + "\t");
swLogFile.Write(oSessions[x].oFlags["x-ProcessInfo"] + "\t");
swLogFile.Write(oSessions[x].oFlags["x-clientPort"] + "\t");
if (oSessions[x].oResponse.headers.Exists("Via"))
swLogFile.Write(oSessions[x].oResponse["Via"] + "\t");
else
swLogFile.Write("\t");
var RequestStart:DateTime = oSessions[x].Timers.ClientConnected;
var ResponseFinish:DateTime = oSessions
[x].Timers.ClientDoneResponse;
if (RequestStart != null)
swLogFile.Write(RequestStart.ToString("yyyy-MM-dd
HH:mm:ss.fffff") + "Z\t");
else
swLogFile.Write("\t");
if (ResponseFinish != null)
swLogFile.Write(ResponseFinish.ToString("yyyy-MM-dd
HH:mm:ss.fffff") + "Z\t");
else
swLogFile.Write("\t");
if (ResponseFinish == null || RequestStart == null)
swLogFile.Write("\t");
else
swLogFile.Write((ResponseFinish - RequestStart).TotalMilliseconds
+ "\t");
oSessions[x].utilDecodeResponse();
swLogFile.Write(oSessions[x].oResponse["Content-Length"] + "\t");
oSessions[x].utilGZIPResponse();
swLogFile.Write(oSessions[x].oResponse["Content-Length"] + "\t");
oSessions[x].utilDecodeResponse();
oSessions[x].utilDeflateResponse();
swLogFile.WriteLine(oSessions[x].oResponse["Content-Length"] +
"\t");
}
}
catch (ex)
{
MessageBox.Show(ex);
}
finally
{
if (swLogFile != null )
{
swLogFile.Close();
swLogFile.Dispose();
}
}
}
//end ResponseTiming
> > - Show quoted text -- Hide quoted text -

yegger

unread,
May 12, 2009, 5:43:41 PM5/12/09
to Fiddler
Tony,

I've not had a chance to try your solution for compression. I will
find it useful.
I'll get back to you after trying it. I see how it works.

Initially I was wondering about minification as in:

http://developer.yahoo.net/blog/archives/2007/07/high_performanc_8.html.

I was trying to answer the question, what size reduction would be
possible with minification .

With your code and a minify callout(if thats possible/librray
available in .NET ) I can answer questions about byte size from
unminifioed/uncompressed to minified/compressed and combinations.


Regards,
John
Reply all
Reply to author
Forward
0 new messages