Coder Social home page Coder Social logo

tmi's Introduction

tmi Dependency Status devDependency Status Build Status

TMI (Too Many Images)

Discover your image weight on the web. Find out the image weight in your pages, compare to the BigQuery medians and discover what images you can optimize further.

Install

$ npm install -g tmi

Quick start

Summary:

$ tmi <url>

Examples:

Switch between desktop and mobile strategies:

$ tmi <url> --strategy=mobile

Detailed summary with URLs you can optimize:

$ tmi <url> --verbose

Usage

This module is modelled on psi and follows a very similar API.

When using this module for a production-level build process, registering for an API key from the Google Developer Console is recommended.

var tmi = require('tmi');

tmi({
	// key: '...', optional
	url: 'http://html5rocks.com',
	paths: '',           // optional
	locale: 'en_GB',     // optional
	strategy: 'mobile',  // optional
	threshold: 80        // optional
});

Optionally, a callback is also available with access to the response:

tmi(options, function (err, data) {
	console.log(data.score);
	console.log(data.pageStats);
});

Options

url

Required
Type: string

URL of the page for which the PageSpeed Insights API should generate results.

locale

Type: string
Default: en_US

The locale that results should be generated in (e.g 'en_GB').

strategy

Type: string
Default: desktop

The strategy to use when analyzing the page. Valid values are desktop and mobile.

threshold

Type: number
Default: 70

Threshold score that is needed to pass the pagespeed test

paths

Type: array

An array of URL paths that are appended to the URL

key

Type: string
Default: nokey

Google API Key

Unless Specified defaults to use the free tier on PageSpeed Insights. Good for getting a feel for how well this tool works for you.

CLI support

You will probably want to globally install tmi if using as a CLI. This can be done as follows:

$ npm install --global tmi

You can then casually use it with or without your key:

$ tmi http://www.google.com
$ tmi http://www.google.com --key 'YOUR_KEY_GOES_HERE'

With or without http:// for URLs:

$ tmi chrome.com

Or ask for a more detailed report including image URLs that can be optimized:

$ tmi http://www.google.com --verbose

Similar to gpagespeed, the following optional flags are also supported:

$ tmi <url> --key=<key> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile>
$ tmi http://www.html5rocks.com --strategy=mobile

Good test URLs

Local testing

We plan on adding support for testing localhost and local files in the very near future. Until then, ngrok should be able to help get you mostly there.

License

Apache 2.

tmi's People

Contributors

addyosmani avatar brycebaril avatar cvan avatar dotcode avatar kevva avatar rumblestrut avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.