{"id":15653761,"url":"https://github.com/denar90/psi-ngrok","last_synced_at":"2025-04-30T21:49:38.021Z","repository":{"id":65477286,"uuid":"68481585","full_name":"denar90/psi-ngrok","owner":"denar90","description":"PageSpeed Insights with local server","archived":false,"fork":false,"pushed_at":"2017-02-16T15:10:12.000Z","size":11,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T21:49:31.374Z","etag":null,"topics":["measure","ngrok","optimization","pagespeed","pagespeed-insights","psi","psi-ngrok"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denar90.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-17T22:33:08.000Z","updated_at":"2024-11-06T19:53:45.000Z","dependencies_parsed_at":"2023-01-25T06:35:13.146Z","dependency_job_id":null,"html_url":"https://github.com/denar90/psi-ngrok","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denar90%2Fpsi-ngrok","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denar90%2Fpsi-ngrok/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denar90%2Fpsi-ngrok/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denar90%2Fpsi-ngrok/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denar90","download_url":"https://codeload.github.com/denar90/psi-ngrok/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789306,"owners_count":21644081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["measure","ngrok","optimization","pagespeed","pagespeed-insights","psi","psi-ngrok"],"created_at":"2024-10-03T12:46:58.471Z","updated_at":"2025-04-30T21:49:38.001Z","avatar_url":"https://github.com/denar90.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# psi-ngrok [![Build Status](https://travis-ci.org/denar90/psi-ngrok.svg?branch=master)](https://travis-ci.org/denar90/psi-ngrok)\n\u003e PageSpeed Insights with local project\n\nUses [psi](https://github.com/addyosmani/psi) and [ngrok](https://github.com/inconshreveable/ngrok) for running PageSpeed Insights\nfor locally run web application.\n\nInspired by \n - [@addyosmany](https://github.com/addyosmani)'s [psi](https://github.com/addyosmani/psi)\n - [Grunt Local PSI](http://www.jamescryer.com/2014/06/12/grunt-pagespeed-and-ngrok-locally-testing/)\n - [Gulp Local PSI](https://una.im/gulp-local-psi/)\n\n## Install\n\n```\n$ npm install --save-dev psi-ngrok\n```\n\n\n## Usage\n\n```js\nconst psiNgrok = require('psi-ngrok');\n\npsiNgrok();\n```\n\n### Usage with configuration\n\n```js\nconst psiNgrok = require('psi-ngrok');\n\nconst config = {\n  pages: ['page1.html', 'page2.html'],\n  onBeforeConnect: function() {\n    // do somtheng before ngrok is connected to your host\n  },\n  //called if page passed `threshold` limit\n  onSuccess: function(data) {\n    console.log(data); // all PSI data about page\n  },\n  //called if page didn't pass `threshold` limit\n  onError: function(error) {\n    console.log(error); // error message\n  },\n  options: {\n    threshold: 85\n  }\n};\n\npsiNgrok(config);\n```\n\nAlso look at [recipes](/recipes).\n\n## Usage with Grunt\n\nHere example of using `psi-ngrok` with [grunt-connect](https://github.com/gruntjs/grunt-contrib-connect)\n\n```js\n\nvar psiNgrok = require('psi-ngrok');\n\nmodule.exports = function(grunt) {\n\n  grunt.initConfig({\n    connect: {\n      server: {\n        options: {\n          port: 8000,\n          base: 'public'\n        }\n      }\n    },\n  });\n\n  grunt.loadNpmTasks('grunt-contrib-connect');\n\n  grunt.registerTask('pagespeed', function() {\n    var async = this.async;\n\n    grunt.event.once('connect.server.listening', function(host, port) {\n      psiNgrok({\n        port: port,\n        pages: ['index.html', 'slow.html'],\n        onError: function(error) {\n          grunt.fatal(error);\n        },\n        options: {\n          threshold: 80\n        }\n      }).then(async());\n    });\n  });\n\n  grunt.registerTask('default', ['pagespeed', 'connect:server:keepalive']);\n};\n\n```\n\n#### Want to test it?\n\nRun\n  - `git clone https://github.com/denar90/psi-ngrok \u0026\u0026 cd psi-ngrok \u0026\u0026 npm i`\n  - `npm run grunt-example`\n  \n\n## Usage with Gulp\n\nHere example of using `psi-ngrok` with [gulp-connect](https://github.com/avevlad/gulp-connect)\n\n```js\n\nvar gulp = require('gulp');\nvar connect = require('gulp-connect');\nvar psiNgrok = require('psi-ngrok');\nvar port = 8000;\n\nvar connectServer = function() {\n  return connect.server({\n    root: 'public',\n    port: port\n  });\n};\n\nfunction handleError(err) {\n  console.log(err.toString());\n  process.exit(-1);\n}\n\ngulp.task('pagespeed', function () {\n  psiNgrok({\n    pages: ['index.html', 'slow.html'],\n    port: port,\n    onBeforeConnect: connectServer,\n    onError: handleError,\n    options: {\n      threshold: 80\n    }\n  });\n});\n\ngulp.task('default', ['pagespeed']);\n\n```\n\n#### Want to test it?\n\nRun\n  - `git clone https://github.com/denar90/psi-ngrok \u0026\u0026 cd psi-ngrok \u0026\u0026 npm i`\n  - `npm run gulp-example`\n\n## API\n\n### psiNgrok([config])\n\nReturns a promise for the response data from Google PageSpeed Insights for pages run locally.\n\n#### config\n\nType: `object`\n\n##### strategies\n\nType: `array` \u003cbr\u003e\nDefault: ['mobile', 'desktop'] \u003cbr\u003e\nValues: `mobile`, `desktop`\n\nStrategies to use when analyzing the page.\n\n##### pages\n\nType: `array` \u003cbr\u003e\nDefault: ['/'] \u003cbr\u003e\n\nList of local pages which will be analyzed.\n\n##### port\n\nType: `number` \u003cbr\u003e\nDefault: 8000 \u003cbr\u003e\n\nPort local server running at.\n\n##### onBeforeConnect\n\nType: `function` \u003cbr\u003e\nDefault: Function.prototype \u003cbr\u003e\n\nFunction called before `ngrok` is started.\n\u003e Useful for running local server.\n\n##### onSuccess\n\nType: `function` \u003cbr\u003e\nDefault: Function.prototype \u003cbr\u003e\n\nFunction called each time page(s) passed `threshold` limit. Has `data` argument which consist of all PSI data about page.\n\n##### onError\n\nType: `function` \u003cbr\u003e\nDefault: Function.prototype \u003cbr\u003e\n\nFunction called each time page(s) didn't pass `threshold` limit. Has `error` argument - message about what went wrong.\n\n#### options\n\nType: `object`\n\n\u003e Pretty the same as [psi options](https://github.com/addyosmani/psi#options)\n\n###### key\n\nType: `string`\u003cbr\u003e\nDefault: Free tier\n\nWhen using this module for a production-level build process, registering for an API key from the [Google Developer Console](https://developers.google.com/speed/docs/insights/v1/getting_started#auth) is recommended.\n\n###### locale\n\nType: `string`\u003cbr\u003e\nDefault: `en_US`\n\nLocale results should be generated in.\n\n###### threshold\n\nType: `number`\u003cbr\u003e\nDefault: `70`\n\nThreshold score to pass the PageSpeed test. Useful for setting a performance budget.\n\n\nMIT © [Artem Denysov](https://github.com/denar90)\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenar90%2Fpsi-ngrok","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenar90%2Fpsi-ngrok","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenar90%2Fpsi-ngrok/lists"}