{"id":24133440,"url":"https://github.com/projectwallace/extract-css-core","last_synced_at":"2026-02-26T02:04:33.791Z","repository":{"id":40543087,"uuid":"177344444","full_name":"projectwallace/extract-css-core","owner":"projectwallace","description":"Extract all CSS from a given url, both server side and client side rendered.","archived":false,"fork":false,"pushed_at":"2022-12-10T21:24:05.000Z","size":510,"stargazers_count":36,"open_issues_count":6,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T08:32:02.015Z","etag":null,"topics":["css","extract","extract-css","inline-styling","js-styling","scrape","wallace"],"latest_commit_sha":null,"homepage":"https://www.projectwallace.com/get-css","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/projectwallace.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},"funding":{"github":"bartveneman","patreon":"bartveneman","open_collective":"projectwallace","custom":["https://www.projectwallace.com/sponsor","https://www.paypal.me/bartveneman"]}},"created_at":"2019-03-23T22:00:56.000Z","updated_at":"2024-02-29T05:22:36.000Z","dependencies_parsed_at":"2023-01-26T09:16:03.768Z","dependency_job_id":null,"html_url":"https://github.com/projectwallace/extract-css-core","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectwallace%2Fextract-css-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectwallace%2Fextract-css-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectwallace%2Fextract-css-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectwallace%2Fextract-css-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/projectwallace","download_url":"https://codeload.github.com/projectwallace/extract-css-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233550309,"owners_count":18692826,"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":["css","extract","extract-css","inline-styling","js-styling","scrape","wallace"],"created_at":"2025-01-11T23:37:50.613Z","updated_at":"2025-09-19T04:31:12.803Z","avatar_url":"https://github.com/projectwallace.png","language":"JavaScript","funding_links":["https://github.com/sponsors/bartveneman","https://patreon.com/bartveneman","https://opencollective.com/projectwallace","https://www.projectwallace.com/sponsor","https://www.paypal.me/bartveneman"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003ch1\u003eextract-css-core\u003c/h1\u003e\n\t\u003cp\u003eExtract all CSS from a given url, both server side and client side rendered.\u003c/p\u003e\n\u003c/div\u003e\n\n[![NPM Version](https://img.shields.io/npm/v/extract-css-core.svg)](https://www.npmjs.com/package/extract-css-core)\n![Node.js CI](https://github.com/bartveneman/extract-css-core/workflows/Node.js%20CI/badge.svg)\n## Usage\n\n```js\nconst extractCss = require('extract-css-core')\n\nconst css = await extractCss('https://www.projectwallace.com')\n//=\u003e html{font-size:100%} etc.\n```\n\nOr, if you want more details:\n\n```js\nconst entries = await extractCss('https://www.projectwallace.com', {\n\torigins: 'include'\n})\n\n// entries will look something like this\n[\n\t{\n\t\thref: 'https://www.projectwallace.com',\n\t\ttype: 'link',\n\t\tcss: '@font-face{font-display:swap;font-family:Teko;...'\n\t},\n\t{\n\t\thref: 'https://www.projectwallace.com/client/Seo.0f4fe72f.css',\n\t\ttype: 'style',\n\t\tcss: '.hero__text.svelte-qhblau a{color:var(--teal-400)}...'\n\t},\n\t{\n\t\thref: 'https://www.projectwallace.com/client/some-css-file.css',\n\t\ttype: 'import',\n\t\tcss: '.some-css {}'\n\t},\n\t{\n\t\thref: 'https://www.projectwallace.com',\n\t\ttype: 'inline',\n\t\tcss: '[x-extract-css-inline-style] { position: absolute; }'\n\t}\n]\n```\n\n## Installation\n\n```sh\nnpm install extract-css-core\n# or\nyarn add extract-css-core\n```\n\n## Motivation, solution and shortcomings\n\n### Motivation\n\nExisting packages like\n[get-css](https://github.com/cssstats/cssstats/tree/master/packages/get-css)\nlook at a server-generated piece of HTML and get all the `\u003clink\u003e` and `\u003cstyle\u003e`\ntags from it. This works fine for 100% server rendered pages 👍, but not for pages with\nCSS-in-JS styling and inline styles 👎.\n\n### Solution\n\nThis module uses an instance of Chromium to render a page. This has the benefit\nthat most of the styles can be rendered, even when generated by JavaScript. The\n`document.styleSheets` API is used to get all styles, including CSS-in-JS. Lastly, a plain old `document.querySelectorAll('[style]')` finds all inline styling.\n\n## API\n\n### extractCss(url, [options])\n\nExtract CSS from a page. Returns a Promise that contains the CSS as a single\nString, or an Array of all entries found when the option `origins: 'include'` is passed.\n\n### Options\n\nType: `Object`\n\nDefault: `{}`\n\n#### origins\n\nType: `String`\n\nDefault: `exclude`\n\nPossible values: `exclude`, `include`\n\n#### inlineStyles\n\nType: `String`\n\nDefault: `include`\n\nPossible values: `exclude`, `include`\n\n#### waitUntil\n\nType: `String`\n\nDefault: `networkidle0`\n\nCan be any value as provided by the\n[Puppeteer docs](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).\n\n## Related\n\n- [projectwallace.com/get-css](https://www.projectwallace.com/get-css) - Online version of this package\n- [Wallace CLI](https://github.com/bartveneman/wallace-cli) - Pretty CSS analytics in your terminal\n- [get-css](https://github.com/cssstats/cssstats/tree/master/packages/get-css) - The original get-css from CSSStats\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectwallace%2Fextract-css-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprojectwallace%2Fextract-css-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectwallace%2Fextract-css-core/lists"}