Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Checking The Size Of A Site

synthetics-script
developer

#1

This is a simple API Test which gets the Google homepage and fails if the size of the body is greater than or equal to 200000 bytes.

var assert = require('assert');

$http.get('http://google.com',

 // Callback
  function (err, response, body) {
        console.log(Buffer.byteLength(body, 'utf8') + " bytes");
        assert.ok(Buffer.byteLength(body, 'utf8') < 200000, "Body was larger than 200kB");
  }
);