{"id":24983643,"url":"https://github.com/posthtml/posthtml-webp","last_synced_at":"2025-04-11T20:51:21.380Z","repository":{"id":33846241,"uuid":"162991515","full_name":"posthtml/posthtml-webp","owner":"posthtml","description":"Add webp supporting in your html","archived":false,"fork":false,"pushed_at":"2023-03-04T04:46:14.000Z","size":2151,"stargazers_count":6,"open_issues_count":7,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T21:06:08.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-12-24T13:05:54.000Z","updated_at":"2023-12-18T01:58:05.000Z","dependencies_parsed_at":"2023-02-18T03:30:55.425Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/posthtml-webp","commit_stats":{"total_commits":82,"total_committers":9,"mean_commits":9.11111111111111,"dds":"0.36585365853658536","last_synced_commit":"42d802007b04a55886c9f4ca4b194b64661c48a8"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-webp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-webp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-webp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-webp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-webp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247909140,"owners_count":21016478,"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":"2025-02-04T09:19:59.428Z","updated_at":"2025-04-11T20:51:21.345Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"# posthtml-webp \u003cimg align=\"right\" width=\"220\" height=\"200\" title=\"PostHTML logo\" src=\"http://posthtml.github.io/posthtml/logo.svg\"\u003e\n\n[![NPM][npm]][npm-url]\n[![Deps][deps]][deps-url]\n[![Build][build]][build-badge]\n[![Coverage][cover]][cover-badge]\n[![Standard Code Style][style]][style-url]\n[![Chat][chat]][chat-badge]\n\nThis plugin add webp supporting in your html. Also supports [`\u003camp-img\u003e`](https://amp.dev/documentation/components/amp-img/)\n\n## Install\n```bash\n$ npm i posthtml posthtml-webp\n```\n\n## Usage\n\n``` js\nconst fs = require('fs');\nconst posthtml = require('posthtml');\nconst posthtmlWebp = require('posthtml-webp');\n\nposthtml()\n    .use(posthtmlWebp(/* Plugin options */))\n    .process(html/*, options */)\n    .then(result =\u003e fs.writeFileSync('./after.html', result.html));\n```\n## Example\n\nBefore:\n``` html\n\u003cimg src=\"image.jpg\"\u003e\n\u003camp-img alt=\"photo\" width=\"550\" height=\"368\" layout=\"responsive\" src=\"photo.png\"\u003e\u003c/amp-img\u003e\n```\n\nAfter:\n``` html\n\u003cpicture\u003e\n    \u003csource type=\"image/webp\" srcset=\"image.jpg.webp\"\u003e\n    \u003cimg src=\"image.jpg\"\u003e\n\u003c/picture\u003e\n\u003camp-img alt=\"photo\" width=\"550\" height=\"368\" layout=\"responsive\" src=\"photo.png.webp\"\u003e\n    \u003camp-img alt=\"photo\" width=\"550\" height=\"368\" layout=\"responsive\" src=\"photo.png\" fallback=\"\"\u003e\u003c/amp-img\u003e\n\u003c/amp-img\u003e\n```\n\n## Options\n\n#### `extension`\n\nType: `string`\nDefault: `.webp`\nDescription: *Add custom extension or even prefix*\nExample: `image.jpg =\u003e image.jpg?as=webp (instead of image.jpg.webp)`\n\n#### `replaceExtension`\n\nType: `Boolean`\nDefault: `false`\nDescription: *Replace the extension of the source image with .webp instead of appending .webp to the original filename*\nExample: `image.jpg =\u003e image.webp (instead of image.jpg.webp)`\n\n#### `classIgnore`\n\nType: `Array\u003cstring\u003e`\nDefault: `[]`\nDescription: *list of classes for which the transformation will be ignored*\nExample: `classIgnore: ['ignore-webp']` will ignore transformation for images with the class `ignore-web`\n\n#### `extensionIgnore`\n\nType: `Array\u003cstring\u003e`\nDefault: `[]`\nDescription: *list of extension for which the transformation will be ignored*\nExample: `extensionIgnore: ['svg']` will ignore transformation for images with the `svg` extension\n\n#### `lazySrcset`\n\nType: `String`\nDefault: `data-srcset`\nDescription: *The attribute used for lazy webp loading. Use it if you have lazy attribute for `srcset` on your images. It will be set on created `\u003csource\u003e` to later be processed by external lazy loading library.*\nExample: `lazySrcset: 'my-srcset'` will set `my-srcset` attribute on `\u003csource\u003e`\n\n#### `lazySrc`\n\nType: `String`\nDefault: `data-src`\nDescription: *The attribute used for lazy webp loading. The original `\u003cimg\u003e` may not contain `src` at all, but instead some custom lazy-loading attribute. Or it may contain just a placeholder image inside `src` which shouldn't be used for webp conversion. `lazySrc` will define a custom attribute name to look at when processing your lazy loaded images. Note that `lazySrcset` is still needed even if `\u003cimg\u003e` has only `lazySrc` defined, because `srcset` is the mechanism for defining a source file for the `\u003csource\u003e`. See `lazySrcset` option description.*\nExample: `lazySrc: 'my-src'` will convert an image inside `my-src` attribute, instead of regular `src`.\n\n### License [MIT](LICENSE)\n\n[npm]: https://img.shields.io/npm/v/posthtml-webp.svg\n[npm-url]: https://npmjs.com/package/posthtml-webp\n\n[deps]: https://david-dm.org/posthtml/posthtml-webp.svg\n[deps-url]: https://david-dm.org/posthtml/posthtml-webp\n\n[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg\n[style-url]: http://standardjs.com/\n\n[build]: https://travis-ci.org/posthtml/posthtml-webp.svg\n[build-badge]: https://travis-ci.org/posthtml/posthtml-webp\n\n[cover]: https://coveralls.io/repos/posthtml/posthtml-webp/badge.svg\n[cover-badge]: https://coveralls.io/r/posthtml/posthtml-webp\n\n[chat]: https://badges.gitter.im/posthtml/posthtml.svg\n[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-webp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-webp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-webp/lists"}