Automating the YSLOW score and HAR using Firefox plugins(NetExport,YSlow)

I have used the following url as source for my experiment.

http://tech.groups.yahoo.com/group/exceptional-performance/message/822

Goal : To automate the following

1. To get YSLOW score of  a webpage

2. To get the Http Archive (HAR) of a webpage

Steps followed

1. Setup firefox with a new profile ‘PerformanceTest’.

  • Create a new profile(In Mac) : /Applications/Firefox.app/Contents/MacOS/firefox -P

2. Install the firebug, yslow and netexport plugins into this profile.

3. Create a web application URL to accept the YSLOW and HAR data

  • On mac(using default apache webserver) , create the Perl CGI scripts  under folder /Library/WebServer/CGI-Executables
  • get_yslow_data.pl Scrpt
  • #!/usr/bin/perl -wprint "Content-type: text/html\n\n";
    open FILE, '>/tmp/yslow.txt';
    #print "<pre>\n";if ($ENV{'REQUEST_METHOD'} eq "GET") {$request = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $request,$ENV{'CONTENT_LENGTH'})
    || die "Could not get query\n";
    
    }
    foreach $key (sort keys(%ENV)) {
    print FILE "$key = $ENV{$key}\n";
    }
    print FILE $request;
    close FILE;

     

  • get_har_data.pl script
  • #!/usr/bin/perl -wprint "Content-type: text/html\n\n";
    open FILE, '>/tmp/har.txt';
    #print "<pre>\n";if ($ENV{'REQUEST_METHOD'} eq "GET") {$request = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $request,$ENV{'CONTENT_LENGTH'})
    || die "Could not get query\n";
    
    }
    foreach $key (sort keys(%ENV)) {
    # print FILE "$key = $ENV{$key}\n";
    }
    print FILE $request;
    close FILE;

4. In firefox set the following plugin values

  • extensions.yslow.beaconUrl=http://127.0.0.1/cgi-bin/get_yslow_data.pl
  • extensions.yslow.autorun=true
  • extensions.firebug.netexport.beaconServerURL=http://127.0.0.1/cgi-bin/get_har_data.pl
  • extensions.firebug.netexport.autoExportToServer=true
  • extensions.firebug.netexport.alwaysEnableAutoExport=true
  • In the browser firebug panel, set the ‘AutoExport’ to on.
  • You can also set the send to URL using this panel , in the screenshot you could see that the data is sent to http://www.shwoslow.com

5. Run the firefox from the command line as following. This will generate the files ‘/tmp/yslow.txt’ and ‘/tmp/har.txt’ containing YSLOW and HAR data for that page.

6. Now you can keep this command in your shell/perl script for executing as automated. For example the following script

  • #!/bin/bashFIREFOX="/cygdrive/c/Program Files/Mozilla Firefox/"
    export PATH=$PATH:$FIREFOXURLS="http://www.yahoo.com http://www.google.com"
    for link in `echo $URLS`;
    do
    firefox.exe -P yslow -no-remote $link &
    PID=$!
    sleep 20
    kill $PID
    done

6. Thanks.

Advertisements

9 Responses to Automating the YSLOW score and HAR using Firefox plugins(NetExport,YSlow)

  1. Manivannan says:

    Tried the same scnerio its not working for me in win 7 os pls guide me how to approach this in right way to get the Yslow score.

    • sundergs says:

      what is the exact problem? is NetExport plugin not exporting the HAR (or) setting up the scripts for accepting the HAR file is not working? Please provide detailed problem scenario for me to help you.

  2. Manivannan says:

    Is it possible i can generate Yslow reports without using netexport(HAR).Also clarify that i need to have apache webserver to execute this (■On mac(using default apache webserver) , create the Perl CGI scripts under folder /Library/WebServer/CGI-Executables)

  3. Manivannan says:

    Guide me to do this activity in window 7

  4. Samina ali says:

    I did all the configuration but still its not generating yslow.txt. Only har.txt file is created but its empty.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: