DeutschEnglishFrançais

Google Page Speed for .NET

Description
This little piece of software sends a request to the Google page speed API, then parses the JSON response and presents them in a nice class.

I use this class on this webpage to show the page speed score at the bottom right corner of the site.

Features:
  • Using .NET variables for things like language (CultureInfo) or ResponseCode (HttpStatusCode)
  • Predefined enumerations for ArgumentType, Strategy, SupportedLanguages etc.
  • Uses the 3.5 Framework DataContractJsonSerializer class for deserialization.
  • Automatic combination of the format strings with the arguments.
Download
Project at CodePlex
Example
Url:Strategy:
Example code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Create the object with your google api key
PageSpeedpageSpeed = newPageSpeed("your-pagespeed-api-key");

// Set properties where necessairy, only the url is mandatory.
pageSpeed.Locale = SupportedLanguages.English;
pageSpeed.PrettyPrint = true;
pageSpeed.Strategy = Strategy.Desktop;
pageSpeed.Url = "http://www.microsoft.com";

// If you dont want to send a server side call to the google pagespeed api, you can
// use this property to go to the google pagespeed webpage
// and start a test for your url.
stringdirectGoogleUrl = pageSpeed.DirectGoogleUrl;

// Get the page speed data for the url from the google pagespeed api
PageSpeedDatadata = pageSpeed.GetPageSpeedData();