{"id":17920934,"url":"https://github.com/davidanson/grunt-check-pages","last_synced_at":"2025-06-28T11:04:52.821Z","repository":{"id":19531701,"uuid":"22779314","full_name":"DavidAnson/grunt-check-pages","owner":"DavidAnson","description":"Grunt task that checks various aspects of a web page for correctness.","archived":false,"fork":false,"pushed_at":"2016-05-01T03:02:13.000Z","size":176,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-26T17:06:55.919Z","etag":null,"topics":[],"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/DavidAnson.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-08-09T05:10:36.000Z","updated_at":"2024-01-29T05:33:29.000Z","dependencies_parsed_at":"2022-08-23T17:10:10.347Z","dependency_job_id":null,"html_url":"https://github.com/DavidAnson/grunt-check-pages","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/DavidAnson/grunt-check-pages","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAnson%2Fgrunt-check-pages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAnson%2Fgrunt-check-pages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAnson%2Fgrunt-check-pages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAnson%2Fgrunt-check-pages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavidAnson","download_url":"https://codeload.github.com/DavidAnson/grunt-check-pages/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAnson%2Fgrunt-check-pages/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262419749,"owners_count":23308098,"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":[],"created_at":"2024-10-28T20:29:42.520Z","updated_at":"2025-06-28T11:04:52.799Z","avatar_url":"https://github.com/DavidAnson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-check-pages\n\n\u003e Grunt task that checks various aspects of a web page for correctness.\n\n[![npm version][npm-image]][npm-url]\n[![GitHub tag][github-tag-image]][github-tag-url]\n[![Build status][travis-image]][travis-url]\n[![Coverage][coveralls-image]][coveralls-url]\n[![License][license-image]][license-url]\n\n## Getting Started\n\nThis plugin requires Grunt `~0.4.4` or later.\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-check-pages --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-check-pages');\n```\n\nFor similar functionality without a Grunt dependency, please see the [`check-pages` package](https://github.com/DavidAnson/check-pages).\n\nFor direct use, the [`check-pages-cli` package](https://github.com/DavidAnson/check-pages-cli) wraps `check-pages` with a command-line interface.\n\n## The \"checkPages\" task\n\n### Overview\n\nAn important aspect of creating a web site is validating the structure, content, and configuration of the site's pages. The `checkPages` task provides an easy way to integrate this testing into your normal Grunt workflow.\n\nBy providing a list of pages to scan, the task can:\n\n* Validate each page is accessible\n* Validate all links point to accessible content (similar to the [W3C Link Checker](http://validator.w3.org/checklink))\n* Validate links with query string [file hashes](https://en.wikipedia.org/wiki/List_of_hash_functions) have the expected content\n* Validate all links use the secure [HTTPS protocol](https://en.wikipedia.org/wiki/HTTPS) where possible\n* Validate page structure for XHTML compliance (akin to the [W3C Markup Validation Service](http://validator.w3.org/))\n* Validate a page's response time is below some threshold\n* Validate a page takes advantage of [caching for better performance](https://developers.google.com/speed/docs/insights/LeverageBrowserCaching)\n* Validate a page takes advantage of [compression for better performance](https://developers.google.com/speed/docs/insights/EnableCompression)\n\n### Usage\n\nIn your project's Gruntfile, add a section named `checkPages` to the data object passed into `grunt.initConfig()`.\nThe following example includes all supported options:\n\n```js\ngrunt.initConfig({\n  checkPages: {\n    development: {\n      options: {\n        pageUrls: [\n          'http://localhost:8080/',\n          'http://localhost:8080/blog',\n          'http://localhost:8080/about.html'\n        ],\n        checkLinks: true,\n        linksToIgnore: [\n          'http://localhost:8080/broken.html'\n        ],\n        noEmptyFragments: true,\n        noLocalLinks: true,\n        noRedirects: true,\n        onlySameDomain: true,\n        preferSecure: true,\n        queryHashes: true,\n        checkCaching: true,\n        checkCompression: true,\n        checkXhtml: true,\n        summary: true,\n        terse: true,\n        maxResponseTime: 200,\n        userAgent: 'custom-user-agent/1.2.3'\n      }\n    },\n    production: {\n      options: {\n        pageUrls: [\n          'http://example.com/',\n          'http://example.com/blog',\n          'http://example.com/about.html'\n        ],\n        checkLinks: true,\n        maxResponseTime: 500\n      }\n    }\n  }\n});\n```\n\n### Options\n\n#### pageUrls\n\nType: `Array` of `String`  \nDefault value: `undefined`  \n*Required*\n\n`pageUrls` specifies a list of URLs for web pages the task will check. The list can be empty, but must be present. Wildcards are not supported.\n\nURLs can point to local or remote content via the `http`, `https`, and `file` protocols. `http` and `https` URLs must be absolute; `file` URLs can be relative. Some features (for example, HTTP header checks) are not available with the `file` protocol.\n\nTo store the list outside `Gruntfile.js`, read the array from a JSON file instead: `pageUrls: grunt.file.readJSON('pageUrls.json')`.\n\n#### checkLinks\n\nType: `Boolean`  \nDefault value: `false`\n\nEnabling `checkLinks` causes each link in a page to be checked for validity (i.e., an [HTTP HEAD or GET request](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods) returns success).\n\nFor efficiency, a `HEAD` request is made first and a successful result validates the link. Because some web servers misbehave, a failed `HEAD` request is followed by a `GET` request to definitively validate the link.\n\nThe following element/attribute pairs are used to identify links:\n\n* `a`/`href`\n* `area`/`href`\n* `audio`/`src`\n* `embed`/`src`\n* `iframe`/`src`\n* `img`/`src`\n* `img`/`srcset`\n* `input`/`src`\n* `link`/`href`\n* `object`/`data`\n* `script`/`src`\n* `source`/`src`\n* `source`/`srcset`\n* `track`/`src`\n* `video`/`src`\n* `video`/`poster`\n\n#### linksToIgnore\n\nType: `Array` of `String`  \nDefault value: `undefined`  \nUsed by: `checkLinks`\n\n`linksToIgnore` specifies a list of URLs that should be ignored by the link checker.\n\nThis is useful for links that are not accessible during development or known to be unreliable.\n\n#### noEmptyFragments\n\nType: `Boolean`  \nDefault value: `false`  \nUsed by: `checkLinks`\n\nSet this option to `true` to fail the task if any links contain an empty [fragment identifier (hash)](https://en.wikipedia.org/wiki/Fragment_identifier) such as `\u003ca href=\"#\"\u003e`.\n\nThis is useful to identify placeholder links that haven't been updated.\n\n#### noLocalLinks\n\nType: `Boolean`  \nDefault value: `false`  \nUsed by: `checkLinks`\n\nSet this option to `true` to fail the task if any links to [`localhost`](https://en.wikipedia.org/wiki/Localhost) are encountered.\n\nThis is useful to detect temporary links that may work during development but would fail when deployed.\n\nThe list of host names recognized as `localhost` are:\n\n* localhost\n* 127.0.0.1 (and the rest of the `127.0.0.0/8` address block)\n* ::1 (and its expanded forms)\n\n#### noRedirects\n\nType: `Boolean`  \nDefault value: `false`  \nUsed by: `checkLinks`\n\nSet this option to `true` to fail the task if any [HTTP redirects](https://en.wikipedia.org/wiki/URL_redirection) are encountered.\n\nThis is useful to ensure outgoing links are to the content's canonical location.\n\n#### onlySameDomain\n\nType: `Boolean`  \nDefault value: `false`  \nUsed by: `checkLinks`\n\nSet this option to `true` to block the checking of links on different domains than the referring page.\n\nThis is useful during development when external sites aren't changing and don't need to be checked.\n\n#### preferSecure\n\nType: `Boolean`  \nDefault value: `false`  \nUsed by: `checkLinks`\n\nSet this option to `true` to fail the task if any HTTP links are present where the corresponding HTTPS link is also valid.\n\nThis is useful to ensure outgoing links use a secure protocol wherever possible.\n\n#### queryHashes\n\nType: `Boolean`  \nDefault value: `false`  \nUsed by: `checkLinks`\n\nSet this option to `true` to verify links with [file hashes](https://en.wikipedia.org/wiki/List_of_hash_functions) in the query string point to content that hashes to the expected value.\n\nQuery hashes can be used to [invalidate cached responses](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#invalidating-and-updating-cached-responses) when [leveraging browser caching](https://developers.google.com/speed/docs/insights/LeverageBrowserCaching) via long cache lifetimes.\n\nSupported hash functions are:\n\n* image.png?[crc32](https://en.wikipedia.org/wiki/Cyclic_redundancy_check)=e4f013b5\n* styles.css?[md5](https://en.wikipedia.org/wiki/MD5)=4f47458e34bc855a46349c1335f58cc3\n* archive.zip?[sha1](https://en.wikipedia.org/wiki/SHA-1)=9511fa1a787d021bdf3aa9538029a44209fb5c4c\n\n#### checkCaching\n\nType: `Boolean`  \nDefault value: `false`\n\nEnabling `checkCaching` verifies the HTTP [`Cache-Control`](https://tools.ietf.org/html/rfc2616#section-14.9) and [`ETag`](https://tools.ietf.org/html/rfc2616#section-14.19) response headers are present and valid.\n\nThis is useful to ensure a page makes use of browser caching for better performance.\n\n#### checkCompression\n\nType: `Boolean`  \nDefault value: `false`\n\nEnabling `checkCompression` verifies the HTTP [`Content-Encoding`](https://tools.ietf.org/html/rfc2616#section-14.11) response header is present and valid.\n\nThis is useful to ensure a page makes use of compression for better performance.\n\n#### checkXhtml\n\nType: `Boolean`  \nDefault value: `false`\n\nEnabling `checkXhtml` attempts to parse each URL's content as [XHTML](https://en.wikipedia.org/wiki/XHTML) and fails if there are any structural errors.\n\nThis is useful to ensure a page's structure is well-formed and unambiguous for browsers.\n\n#### summary\n\nType: `Boolean`  \nDefault value: `false`\n\nEnabling the `summary` option logs a summary of each issue found after all checks have completed.\n\nThis makes it easy to pick out failures when running tests against many pages. May be combined with the `terse` option.\n\n#### terse\n\nType: `Boolean`  \nDefault value: `false`\n\nEnabling the `terse` option suppresses the logging of each check as it runs, instead displaying a brief overview at the end.\n\nThis is useful for scripting or to reduce output. May be combined with the `summary` option.\n\n#### maxResponseTime\n\nType: `Number`  \nDefault value: `undefined`\n\n`maxResponseTime` specifies the maximum amount of time (in milliseconds) a page request can take to finish downloading.\n\nRequests that take more time will trigger a failure (but are still checked for other issues).\n\n#### userAgent\n\nType: `String`  \nDefault value: `grunt-check-pages/x.y.z`\n\n`userAgent` specifies the value of the HTTP [`User-Agent`](https://tools.ietf.org/html/rfc2616#section-14.43) header sent with all page/link requests.\n\nThis is useful for pages that alter their behavior based on the user agent. Setting the value `null` omits the `User-Agent` header entirely.\n\n## Release History\n\n* 0.1.0 - Initial release, support for `checkLinks` and `checkXhtml`.\n* 0.1.1 - Tweak README for better formatting.\n* 0.1.2 - Support page-only mode (no link or XHTML checks), show response time for requests.\n* 0.1.3 - Support `maxResponseTime` option, buffer all page responses, add \"no-cache\" header to requests.\n* 0.1.4 - Support `checkCaching` and `checkCompression` options, improve error handling, use [`gruntMock`](https://www.npmjs.com/package/gruntmock).\n* 0.1.5 - Support `userAgent` option, weak entity tags, update `nock` dependency.\n* 0.2.0 - Support `noLocalLinks` option, rename `disallowRedirect` option to `noRedirects`, switch to [`ESLint`](http://eslint.org/), update `superagent` and `nock` dependencies.\n* 0.3.0 - Support `queryHashes` option for CRC-32/MD5/SHA-1, update `superagent` dependency.\n* 0.4.0 - Rename `onlySameDomainLinks` option to `onlySameDomain`, fix handling of redirected page links, use page order for links, update all dependencies.\n* 0.5.0 - Show location of redirected links with `noRedirects` option, switch to `crc-hash` dependency.\n* 0.6.0 - Support `summary` option, update `crc-hash`, `grunt-eslint`, `nock` dependencies.\n* 0.6.1 - Add badges for automated build and coverage info to README (along with npm, GitHub, and license).\n* 0.6.2 - Switch from `superagent` to `request`, update `grunt-eslint` and `nock` dependencies.\n* 0.7.0 - Move task implementation into reusable `check-pages` package.\n* 0.7.1 - Fix misreporting of \"Bad link\" for redirected links when noRedirects enabled.\n* 0.8.0 - Suppress redundant link checks, support `noEmptyFragments` option, update dependencies.\n* 0.9.0 - Add support for checking local content via the 'file:' protocol, update dependencies.\n* 0.10.0 - International URLs, `preferSecure` option, `terse` option, `srcset`, update dependencies.\n\n[npm-image]: https://img.shields.io/npm/v/grunt-check-pages.svg\n[npm-url]: https://www.npmjs.com/package/grunt-check-pages\n[github-tag-image]: https://img.shields.io/github/tag/DavidAnson/grunt-check-pages.svg\n[github-tag-url]: https://github.com/DavidAnson/grunt-check-pages\n[travis-image]: https://img.shields.io/travis/DavidAnson/grunt-check-pages/master.svg\n[travis-url]: https://travis-ci.org/DavidAnson/grunt-check-pages\n[coveralls-image]: https://img.shields.io/coveralls/DavidAnson/grunt-check-pages/master.svg\n[coveralls-url]: https://coveralls.io/r/DavidAnson/grunt-check-pages\n[license-image]: https://img.shields.io/npm/l/grunt-check-pages.svg\n[license-url]: http://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidanson%2Fgrunt-check-pages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidanson%2Fgrunt-check-pages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidanson%2Fgrunt-check-pages/lists"}