Get the ZIP file
(updated to 1.1)
- bw-test.js: the javascript file you need
- image-*.png: bandwidth testing images
- README: brief instructions
- tests/*.html: simple tests that show you how to use the code
base_url
variable points to the URL where the images are. This means that you can offload the javascript onto a CDN and keep the images on your own server. You shouldn't push the images to a CDN, because that will measure your user's effective bandwidth when accessing the CDN and not your server, which is presumably what you'd like to know. You'd probably also want to minify the javascript before using it. I'll provide a minified version in a later release.The test runs automatically once the code is included, so to avoid interfering with the download of your page's components, make sure it's the last thing on your page.
If you want to get a little more adventurous, you could set the
auto_run
variable to false, and then start the test whenever you're ready to run it by calling PERFORMANCE.BWTest.run()
.Once the test completes, it will fire the
PERFORMANCE.BWTest.oncomplete
event. You can attach your own function to this event to do what you want with the results. You can also beacon back the results to your server by setting the beacon_url
variable. This URL will be called with the following URL parameters:- bw: The median bandwidth in bytes/second
- latency: The median HTTP latency in milliseconds
- bwg: The geometric mean of bandwidth measurements in bytes/second
- latencyg: The geometric mean of HTTP latency measurements in milliseconds
The code is distributed under the BSD license, so use it as you like.
Note that all variables mentioned above are in the
PERFORMANCE.BWTest
namespace.
0 comments :
Post a Comment