Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
grunt-perfbudget
Advanced tools
Grunt task for Performance Budgeting
grunt-perfbudget is a Grunt.js task for enforcing a performance budget (more on performance budgets). It uses the wonderful webpagetest.org and the WebPagetest API Wrapper for NodeJS created by Marcel Duran.
grunt-perfbudget uses either a public or private instance of WebPagetest to perform tests on a specified URL. It compares test results to budgets you specify. If the budget is met, the tasks successfully completes. If it the page exceeds your performance budgets, the task fails and informs you why.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-perfbudget --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-perfbudget');
While grunt-perfbudget provides defaults for most configurable options, it does require the URL to be tested, as well as an API key to use if testing against the public instance of WebPagetest. For more information on obtaining a key, see this thread on the WebPagetest forums.
These can be set in your Gruntfile.js config file like so:
perfbudget: {
default: {
options: {
url: 'http://google.com',
key: 'API_KEY_HERE'
}
}
}
With these configuration properties set, you can add perfbudget
to your default tasks list. That'll look something like this:
grunt.registerTask('default', ['jshint', 'perfbudget']);
With this in place, grunt-perfbudget will now test your site against the default performance budget settings to see if you're passing.
grunt-perfbudget takes the following options:
Type String
Default value: NONE
The url you want to perform the tests on.
Type String
Default value: NONE
The API Key for the public instance of WPT. Not needed if using a private instance of webpagetest
Type String
Default value: 'Dulles_Nexus5'
The default WPT location/device to conduct the test using.
Type String
Default value: 'www.webpagetest.org'
The WPT instance to conduct the tests with.
Type String
Default value: NONE
The connectivity profile to use. WPT provides the following options: Cable, DSL, FIOS, Dial, 3G, Native, custom.
Type String
Default value: NONE
The download bandwith in Kbps. Used when connectivity is set to custom
.
Type String
Default value: NONE
The upload bandwith in Kbps. Used when connectivity is set to custom
.
Type String
Default value: NONE
The RTT latency in milliseconds. Used when connectivity is set to custom
.
Type String
Default value: NONE
The package loss rate (percentage of packets to drop). Used when connectivity is set to custom
.
Type Object
Allows you to specify your budget for a number of different variables, including:
Type String
Default value: NONE
The budget for visually complete in millseconds.
Type String
Default value: 1000
The budget for start render time in millseconds.
Type String
Default value: NONE
The budget for load time in millseconds.
Type String
Default value: NONE
The budget for document.complete
in millseconds.
Type String
Default value: NONE
The budget for fully loaded time in millseconds.
Type String
Default value: NONE
The budget for overall weight in bytes.
Type String
Default value: NONE
The budget for number of bytes downloaded before the Document Complete time.
Type String
Default value: NONE
The budget for overall number of requests.
Type String
Default value: NONE
The budget for number of requests made before the Document Complete time.
Type String
Default value: 1000
The budget for calculated SpeedIndex.
perfbudget: {
default: {
options: {
url: 'http://google.com',
key: 'API_KEY_HERE'
}
}
}
perfbudget: {
default: {
options: {
url: 'http://google.com',
key: 'API_KEY_HERE',
budget: {
visualComplete: '4000',
speedIndex: '1500'
}
}
}
}
perfbudget: {
default: {
options: {
url: 'http://google.com',
wptInstance: 'http://PRIVATE_INSTANCE.com',
budget: {
visualComplete: '4000',
speedIndex: '1500'
}
}
}
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
(Nothing yet)
FAQs
Grunt task for Performance Budgeting
The npm package grunt-perfbudget receives a total of 82 weekly downloads. As such, grunt-perfbudget popularity was classified as not popular.
We found that grunt-perfbudget demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.