{"id":15105521,"url":"https://github.com/reatlat/eleventy-plugin-speculation-rules","last_synced_at":"2026-03-14T08:01:18.171Z","repository":{"id":236683816,"uuid":"792925850","full_name":"reatlat/eleventy-plugin-speculation-rules","owner":"reatlat","description":"An Eleventy plugin adds support for the Speculation Rules API, which allows defining rules by which certain URLs are dynamically prefetched or prerendered based on user interaction.","archived":false,"fork":false,"pushed_at":"2024-07-20T23:23:12.000Z","size":72,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-09T05:27:31.098Z","etag":null,"topics":["11ty","11ty-plugin","eleventy","eleventy-plugin","npm-package","optimization","performance","speculation-rules"],"latest_commit_sha":null,"homepage":"https://eleventy-plugin-speculation-rules.netlify.app","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/reatlat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"reatlat","custom":"https://www.paypal.me/reatlat"}},"created_at":"2024-04-28T00:03:26.000Z","updated_at":"2024-10-16T07:46:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"aaaab34a-8798-466e-9eab-0e526fef609e","html_url":"https://github.com/reatlat/eleventy-plugin-speculation-rules","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"709859b7f8c9e0f868320858fa8737b309214f77"},"previous_names":["reatlat/eleventy-plugin-speculation-rules"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/reatlat/eleventy-plugin-speculation-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reatlat%2Feleventy-plugin-speculation-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reatlat%2Feleventy-plugin-speculation-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reatlat%2Feleventy-plugin-speculation-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reatlat%2Feleventy-plugin-speculation-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reatlat","download_url":"https://codeload.github.com/reatlat/eleventy-plugin-speculation-rules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reatlat%2Feleventy-plugin-speculation-rules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270796224,"owners_count":24647320,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["11ty","11ty-plugin","eleventy","eleventy-plugin","npm-package","optimization","performance","speculation-rules"],"created_at":"2024-09-25T20:40:34.443Z","updated_at":"2025-12-24T18:36:31.646Z","avatar_url":"https://github.com/reatlat.png","language":"JavaScript","funding_links":["https://github.com/sponsors/reatlat","https://www.paypal.me/reatlat"],"categories":[],"sub_categories":[],"readme":"# eleventy-plugin-speculation-rules\n[![npm](https://img.shields.io/npm/v/eleventy-plugin-speculation-rules.svg)](https://npmjs.com/package/eleventy-plugin-speculation-rules)\n[![npm](https://img.shields.io/npm/dt/eleventy-plugin-speculation-rules.svg)](https://npmjs.com/package/eleventy-plugin-speculation-rules)\n[![license](https://img.shields.io/npm/l/eleventy-plugin-speculation-rules.svg)](https://npmjs.com/package/eleventy-plugin-speculation-rules)\n\nThis plugin adds support for the [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API), which allows defining rules by which certain URLs are dynamically prefetched or prerendered based on user interaction.\n\nDemo: [https://eleventy-plugin-speculation-rules.netlify.app/](https://eleventy-plugin-speculation-rules.netlify.app/)\n\n## Requirements\n\n- Eleventy 2.0 or higher (CJS) / Eleventy 3.0 or higher (ESM)\n\n## Installation\n\nInstall the plugin from [npm](https://www.npmjs.com/package/eleventy-plugin-speculation-rules):\n\n```\nnpm install eleventy-plugin-speculation-rules --save-dev\n```\n\n## Configuration\n\n- `mode` - The speculation mode. Default: `prerender`, options: `prefetch`, `prerender`\n- `eagerness` - The eagerness level for speculation. Default: `moderate`, options: `conservative`, `moderate`, `eager`\n- `noPrerenderSelector` - CSS selector for links that should not be prerendered. Default: `.no-prerender`\n- `include` - Array of URL patterns to include. Default: `[]`\n- `exclude` - Array of URL patterns to exclude. Default: `[]`\n\nBy default, the plugin excludes `.zip` and `.pdf` files, as well as links with `rel=\"nofollow\"`.\n\n## Usage\n\nAdd it to your [Eleventy Config](https://www.11ty.dev/docs/config/) file:\n\n**ESM (Eleventy 3.x):**\n\n```js\nimport eleventyPluginSpeculationRules from 'eleventy-plugin-speculation-rules';\n\nexport default function (eleventyConfig) {\n    eleventyConfig.addPlugin(eleventyPluginSpeculationRules);\n};\n```\n\n**CommonJS (Eleventy 2.x):**\n\n```js\nconst eleventyPluginSpeculationRules = require('eleventy-plugin-speculation-rules');\n\nmodule.exports = function (eleventyConfig) {\n    eleventyConfig.addPlugin(eleventyPluginSpeculationRules);\n};\n```\n\n### Advanced usage:\n\n```js\nimport eleventyPluginSpeculationRules from 'eleventy-plugin-speculation-rules';\n\nexport default function (eleventyConfig) {\n    eleventyConfig.addPlugin(eleventyPluginSpeculationRules, {\n        mode: 'prerender',\n        eagerness: 'moderate',\n        noPrerenderSelector: '.no-prerender',\n        include: [],\n        exclude: ['/admin/*']\n    });\n};\n```\n\n## What does it do?\n\nThe plugin injects a `\u003cscript type=\"speculationrules\"\u003e` tag into the `\u003chead\u003e` of your HTML pages with rules that tell the browser which links to prefetch or prerender.\n\nA filter can be used to exclude certain URL paths from being eligible for prefetching and prerendering. Alternatively, you can add the `.no-prerender` CSS class to any link (`\u003ca\u003e` tag) that should not be prerendered.\n\n### Speculation Mode\n\n- `prefetch` - The browser will prefetch the URL when the user hovers over the link.\n- `prerender` - The browser will prerender the URL when the user hovers over the link.\n\nPrerendering will lead to faster load times than prefetching. However, in case of interactive content, prefetching may be a safer choice.\n\n### Speculation Eagerness\n\n- `conservative` - Speculates only on click\n- `moderate` - Speculates on hover\n- `eager` - Speculates on slightest indication\n\nThe eagerness setting defines the heuristics based on which the loading is triggered. \"Eager\" will have the minimum delay to start speculative loads, \"Conservative\" increases the chance that only URLs the user actually navigates to are loaded.\n\n## Browser support\n\nThe Speculation Rules API is a new web API, and the functionality used by the plugin is supported in Chromium-based browsers such as Chrome, Edge, or Opera using version 121 or above. Other browsers such as Safari and Firefox will ignore the functionality with no ill effects but will not benefit from the speculative loading. Note that extensions may disable preloading by default (for example, uBlock Origin does this).\n\n- [Browser support for the Speculation Rules API in general](https://caniuse.com/mdn-html_elements_script_type_speculationrules)\n- [Information on document rules syntax support used by the plugin](https://developer.chrome.com/blog/chrome-121-beta#speculation_rules_api)\n\n## Contributing\n\nIf you notice an issue, feel free to [open an issue](https://github.com/reatlat/eleventy-plugin-speculation-rules/issues).\n\n1. Fork this repo\n2. Clone `git clone git@github.com:reatlat/eleventy-plugin-speculation-rules.git`\n3. Install dependencies `npm install`\n4. Build `npm run build`\n5. Serve locally `npm run dev`\n\n\n## License\n\nThe code is available under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freatlat%2Feleventy-plugin-speculation-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freatlat%2Feleventy-plugin-speculation-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freatlat%2Feleventy-plugin-speculation-rules/lists"}