npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wlrp__speed-tracker

v1.0.0

Published

WLRP request speed & load time tracking client for site health monitoring

Downloads

6

Readme

request-speed.js

A JavaScript library that helps developers measure and track the performance of their web pages

This library's purpose is twofold. Used locally for development, it can help you assess how time is spent loading by your application among the different layers. Used on production sites, it helps gather the data necessary to develop and maintain lightning-fast websites and applications - that is, real-life statistics about the load times experienced by your users instead of having to rely on data approximated by various pagespeed services.

Request-speed.js relies on the browser's Navigation Timing API, so IE8 and lower are not supported. Support may be added later but reporting accuracy won't be the same.

How it works

Implementing request-speed.js is quite flexible: just import the library into your project and create an instance of RequestSpeed with your desired config wherever you want in your page, it will wait for the appropriate time to report its results. Below you can find a list of configuration options and their defaults.

Config


var config = {
	raw: false, // Used to determine if the results should contain all the timings or an aggregate report
	noConsole: false, // If set to true, no the results won't be displayed to the console. Useful for production
	reportUrl: false // False to skip sending remote report, or an URL string to the endpoint to send data to
	extraData: false // An object containing additional data you may want to send along with the report
};

Adding keys to the report

The data sent to the remote endpoint can be customized to suit any data structure your application may require. This is useful to pass any API key or identifying information necessary to access your server. To add data to the report, simply pass a JavaScript object containing your custom keys and values to the constructor as the config object's extraData key. The keys in this object will be merged with the speed report, so be aware that if you use the same keys as request-speed.js does for its reports, those keys will be overwritten with your custom values.

The report

The speed report contains different information depending on the value of config.raw. If a raw report is requested, the entire contents of window.performance.timing will be returned as provided by the browser. If not, request-speed.js creates a simplified list of loadtime data typically of interest to developers. This report contains the following:

report.requestTime

The time the request was made. Useful for organising your data for later analysis.

report.firstByte

The time to first byte, as measured from the value of requestTime. A high value indicates possible problems with your network or your application's HTTP layer.

report.domReady

The time it takes for the DOM to become interactive, as measured from the value of requestTime. Useful to determine the responsiveness of your application.

report.loadTime

The time it takes for all the contents of the document to be loaded, including scripts, styles, images and other assets, as measured from the value of requestTime. A high value may indicate that your application uses too many assets or assets that aren't optimised for speed.

Full example


<!DOCTYPE html>
<html>
	<head>
		<script type="text/javascript" src="path/to/request-speed.js"></script>
	</head>
	<body>
		// your content
		<script type="text/javascript">
			new RequestSpeed({
				raw: false,
				noConsole: true,
				reportUrl: 'http://endpoint.example.com',
				extraData: {
					apiKey: 'abc123',
					...
				}
			});
		</script>
	</body>
</html>