├── .editorconfig ├── .gitignore ├── .travis.yml ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '6' 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const isBlank = require('is-blank') 4 | const a11y = require('a11y') 5 | const tmi = require('a11y') 6 | const psi = require('psi') 7 | const getCss = require('get-css') 8 | const domStats = require('dom-stats') 9 | const cssstats = require('cssstats') 10 | const got = require('got') 11 | const pify = require('pify') 12 | const normalizeUrl = require('normalize-url') 13 | 14 | module.exports = (url, opts) => { 15 | if (isBlank(url) || typeof url !== 'string') { 16 | throw new TypeError('scrutinize expected a url as a string') 17 | } 18 | 19 | url = normalizeUrl(url) 20 | 21 | const options = Object.assign({}, opts || {}, { 22 | getCss: { 23 | ignoreCerts: true, 24 | timeout: 2000 25 | } 26 | }) 27 | 28 | 29 | return new Promise((resolve, reject) => { 30 | Promise.all([ 31 | css(url, options.getCss), 32 | pagespeed(url, options.psi), 33 | accessibility(url), 34 | dom(url) 35 | ]) 36 | .then(results => results.reduce((p, c) => Object.assign({}, p, c))) 37 | .then(resolve) 38 | .catch(reject) 39 | }) 40 | } 41 | 42 | const css = (url, options) => getCss(url, options).then(css => ({ css: cssstats(css.css) })) 43 | const pagespeed = (url, options) => psi(url, options).then(data => ({ psi: data })) 44 | const accessibility = url => pify(a11y)(url).then(data => ({ a11y: data })) 45 | const dom = url => got(url).then(res => ({ dom: domStats(res.body, { ignoreZeroCounts: true }) })) 46 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 John Otander 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scrutinize", 3 | "description": "Scrutinize the performance and accessibility of a url", 4 | "author": "John Otander", 5 | "version": "2.0.0-beta.1", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "ava -v" 9 | }, 10 | "repository": "johnotander/scrutinize", 11 | "keywords": [ 12 | "scrutinize", 13 | "css", 14 | "html", 15 | "page-speed", 16 | "images", 17 | "a11y", 18 | "accessibility" 19 | ], 20 | "license": "MIT", 21 | "dependencies": { 22 | "a11y": "^0.4.1", 23 | "cssstats": "^3.0.0-beta.2", 24 | "dom-stats": "^2.0.0", 25 | "get-css": "^1.2.1", 26 | "got": "^6.5.0", 27 | "is-blank": "1.1.0", 28 | "is-present": "1.0.0", 29 | "normalize-url": "^1.6.1", 30 | "pify": "^2.3.0", 31 | "psi": "^2.0.4", 32 | "tmi": "^1.0.3" 33 | }, 34 | "devDependencies": { 35 | "ava": "^0.16.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # scrutinize [![Build Status](https://secure.travis-ci.org/johnotander/scrutinize.png?branch=master)](https://travis-ci.org/johnotander/scrutinize) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) 2 | 3 | Scrutinize a url by analyzing its css, html, a11y, images, and pagespeed score. 4 | 5 | ## Installation 6 | 7 | ```sh 8 | npm i -S scrutinize 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```javascript 14 | const scrutinize = require('scrutinize') 15 | 16 | scrutinize('google.com') 17 | .then(doStuff) 18 | .catch(handleError) 19 | ``` 20 | 21 | ## Related 22 | 23 | - [cssstats](https://github.com/jxnblk/css-statistics) 24 | - [a11y](https://github.com/addyosmani/a11y) 25 | - [psi](https://github.com/addyosmani/psi) 26 | - [tmi](https://github.com/addyosmani/tmi) 27 | - [dom-stats](https://github.com/johnotander/dom-stats) 28 | 29 | ## License 30 | 31 | MIT 32 | 33 | ## Contributing 34 | 35 | 1. Fork it 36 | 2. Create your feature branch (`git checkout -b my-new-feature`) 37 | 3. Commit your changes (`git commit -am 'Add some feature'`) 38 | 4. Push to the branch (`git push origin my-new-feature`) 39 | 5. Create new Pull Request 40 | 41 | Crafted with <3 by John Otander ([@4lpine](https://twitter.com/4lpine)). 42 | 43 | *** 44 | 45 | > This package was initially generated with [yeoman](http://yeoman.io) and the [p generator](https://github.com/johnotander/generator-p.git). 46 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const test = require('ava') 2 | const scrutinize = require('./') 3 | 4 | test('throws with no url', t => t.throws(scrutinize)) 5 | 6 | test('returns the expected data', async t => { 7 | const data = await scrutinize('johnotander.com') 8 | console.log(data) 9 | 10 | t.truthy(data) 11 | }) 12 | --------------------------------------------------------------------------------