{"id":19091001,"url":"https://github.com/jandc/css-from-html-extractor","last_synced_at":"2025-08-08T10:43:14.383Z","repository":{"id":56996374,"uuid":"71052668","full_name":"JanDC/css-from-html-extractor","owner":"JanDC","description":"PHP library which determines which css is used from html snippets.","archived":false,"fork":false,"pushed_at":"2019-11-07T12:17:29.000Z","size":43,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-10T20:48:00.992Z","etag":null,"topics":["css","html-extractor","php-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JanDC.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":"2016-10-16T13:40:26.000Z","updated_at":"2025-03-06T18:20:36.000Z","dependencies_parsed_at":"2022-08-21T12:20:54.492Z","dependency_job_id":null,"html_url":"https://github.com/JanDC/css-from-html-extractor","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/JanDC/css-from-html-extractor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanDC%2Fcss-from-html-extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanDC%2Fcss-from-html-extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanDC%2Fcss-from-html-extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanDC%2Fcss-from-html-extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JanDC","download_url":"https://codeload.github.com/JanDC/css-from-html-extractor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanDC%2Fcss-from-html-extractor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269409960,"owners_count":24412143,"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-08T02:00:09.200Z","response_time":72,"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":["css","html-extractor","php-library"],"created_at":"2024-11-09T03:10:39.360Z","updated_at":"2025-08-08T10:43:14.352Z","avatar_url":"https://github.com/JanDC.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSS from HTML extractor\n\nPhp library which determines which css is used from html snippets.\nIt is used in jandc/critical-css to automatically and dynamically determine critical css on a per page basis.\n\n\n### Installation\n``\ncomposer require jandc/css-from-html-extractor\n``\n### Usage\n\n#### With Twig\n###### Register Extension\n```php\nuse CSSFromHTMLExtractor\\Twig\\Extension as ExtractorExtension;\n\n$extension = new ExtractorExtension()\n$extension-\u003eaddBaseRules('path/to/css');\n\n/** @var Twig_Environment $twig */\n$twig-\u003eaddExtension($extension);\n```\n###### Mark the regions of your templates with the provided blocks\n```twig\n{% fold %}\n\u003cdiv class=\"my-class\"\u003e\n...\n\u003c/div\u003e\n{% endfold %}\n```\n\n###### Retrieve the resulting css from the extension\n\n```php\n$extension = $twigEnvironment-\u003egetExtension(ExtractorExtension::class);\n$extension-\u003ebuildCriticalCssFromSnippets();\n```\n\n\n#### Handling raw HTML\n```php\n$cssFromHTMLExtractor = new CssFromHTMLExtractor();\n$cssFromHTMLExtractor-\u003eaddBaseRules('path/to/css');\n$cssFromHTMLExtractor-\u003eaddHtmlToStore($rawHtml);\n$extractedCss = $cssFromHTMLExtractor-\u003ebuildExtractedRuleSet();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandc%2Fcss-from-html-extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjandc%2Fcss-from-html-extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandc%2Fcss-from-html-extractor/lists"}