{"id":15633601,"url":"https://github.com/voku/htmlmin","last_synced_at":"2025-05-15T03:07:54.029Z","repository":{"id":41085527,"uuid":"71027387","full_name":"voku/HtmlMin","owner":"voku","description":":clamp: HtmlMin: HTML Compressor and Minifier via PHP","archived":false,"fork":false,"pushed_at":"2025-04-21T04:29:16.000Z","size":515,"stargazers_count":167,"open_issues_count":20,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-15T03:07:50.100Z","etag":null,"topics":["hacktoberfest","html","htmlcompressor","htmlmin","minifies","minify","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/voku.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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,"zenodo":null},"funding":{"github":["voku"],"patreon":"voku","custom":"https://www.paypal.me/moelleken"}},"created_at":"2016-10-16T03:13:22.000Z","updated_at":"2025-04-12T08:43:24.000Z","dependencies_parsed_at":"2023-09-27T15:44:47.805Z","dependency_job_id":"227c7c75-649d-4b05-b436-9fd00678cc8f","html_url":"https://github.com/voku/HtmlMin","commit_stats":{"total_commits":210,"total_committers":18,"mean_commits":"11.666666666666666","dds":0.4380952380952381,"last_synced_commit":"872dac444652d30791ca5d0c23fbe1e6b9cab5bc"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voku%2FHtmlMin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voku%2FHtmlMin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voku%2FHtmlMin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voku%2FHtmlMin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voku","download_url":"https://codeload.github.com/voku/HtmlMin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264769,"owners_count":22041794,"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":["hacktoberfest","html","htmlcompressor","htmlmin","minifies","minify","php"],"created_at":"2024-10-03T10:49:30.778Z","updated_at":"2025-05-15T03:07:53.963Z","avatar_url":"https://github.com/voku.png","language":"PHP","funding_links":["https://github.com/sponsors/voku","https://patreon.com/voku","https://www.paypal.me/moelleken","https://www.patreon.com/voku","https://paypal.me/moelleken","https://www.patreon.com/voku/posts"],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/voku/HtmlMin/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/voku/HtmlMin/actions)\n[![Coverage Status](https://coveralls.io/repos/github/voku/HtmlMin/badge.svg?branch=master)](https://coveralls.io/github/voku/HtmlMin?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a433ed2b3b7546b3a1c520310222a601)](https://www.codacy.com/app/voku/HtmlMin?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=voku/HtmlMin\u0026amp;utm_campaign=Badge_Grade)\n[![Latest Stable Version](https://poser.pugx.org/voku/html-min/v/stable)](https://packagist.org/packages/voku/html-min) \n[![Total Downloads](https://poser.pugx.org/voku/html-min/downloads)](https://packagist.org/packages/voku/html-min) \n[![License](https://poser.pugx.org/voku/html-min/license)](https://packagist.org/packages/voku/html-min)\n[![Donate to this project using Paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/moelleken)\n[![Donate to this project using Patreon](https://img.shields.io/badge/patreon-donate-yellow.svg)](https://www.patreon.com/voku)\n\n# :clamp: HtmlMin: HTML Compressor and Minifier for PHP\n\n### Description\n\nHtmlMin is a fast and very easy to use PHP library that minifies given HTML5 source by removing extra whitespaces, comments and other unneeded characters without breaking the content structure. As a result pages become smaller in size and load faster. It will also prepare the HTML for better gzip results, by re-ranging (sort alphabetical) attributes and css-class-names.\n\n\n### Install via \"composer require\"\n\n```shell\ncomposer require voku/html-min\n```\n\n### Quick Start\n\n```php\nuse voku\\helper\\HtmlMin;\n\n$html = \"\n\u003chtml\u003e\n  \\r\\n\\t\n  \u003cbody\u003e\n    \u003cul style=''\u003e\n      \u003cli style='display: inline;' class='foo'\u003e\n        \\xc3\\xa0\n      \u003c/li\u003e\n      \u003cli class='foo' style='display: inline;'\u003e\n        \\xc3\\xa1\n      \u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/body\u003e\n  \\r\\n\\t\n\u003c/html\u003e\n\";\n$htmlMin = new HtmlMin();\n\necho $htmlMin-\u003eminify($html); \n// '\u003chtml\u003e\u003cbody\u003e\u003cul\u003e\u003cli class=foo style=\"display: inline;\"\u003e à \u003cli class=foo style=\"display: inline;\"\u003e á \u003c/ul\u003e'\n```\n\n### Options\n\n```php\nuse voku\\helper\\HtmlMin;\n\n$htmlMin = new HtmlMin();\n\n/* \n * Protected HTML (inline css / inline js / conditional comments) are still protected,\n *    no matter what settings you use.\n */\n\n$htmlMin-\u003edoOptimizeViaHtmlDomParser();               // optimize html via \"HtmlDomParser()\"\n$htmlMin-\u003edoRemoveComments();                         // remove default HTML comments (depends on \"doOptimizeViaHtmlDomParser(true)\")\n$htmlMin-\u003edoSumUpWhitespace();                        // sum-up extra whitespace from the Dom (depends on \"doOptimizeViaHtmlDomParser(true)\")\n$htmlMin-\u003edoRemoveWhitespaceAroundTags();             // remove whitespace around tags (depends on \"doOptimizeViaHtmlDomParser(true)\")\n$htmlMin-\u003edoOptimizeAttributes();                     // optimize html attributes (depends on \"doOptimizeViaHtmlDomParser(true)\")\n$htmlMin-\u003edoRemoveHttpPrefixFromAttributes();         // remove optional \"http:\"-prefix from attributes (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveHttpsPrefixFromAttributes();        // remove optional \"https:\"-prefix from attributes (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoKeepHttpAndHttpsPrefixOnExternalAttributes(); // keep \"http:\"- and \"https:\"-prefix for all external links \n$htmlMin-\u003edoMakeSameDomainsLinksRelative(['example.com']); // make some links relative, by removing the domain from attributes\n$htmlMin-\u003edoRemoveDefaultAttributes();                // remove defaults (depends on \"doOptimizeAttributes(true)\" | disabled by default)\n$htmlMin-\u003edoRemoveDeprecatedAnchorName();             // remove deprecated anchor-jump (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveDeprecatedScriptCharsetAttribute(); // remove deprecated charset-attribute - the browser will use the charset from the HTTP-Header, anyway (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveDeprecatedTypeFromScriptTag();      // remove deprecated script-mime-types (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveDeprecatedTypeFromStylesheetLink(); // remove \"type=text/css\" for css links (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveDeprecatedTypeFromStyleAndLinkTag(); // remove \"type=text/css\" from all links and styles\n$htmlMin-\u003edoRemoveDefaultMediaTypeFromStyleAndLinkTag(); // remove \"media=\"all\" from all links and styles\n$htmlMin-\u003edoRemoveDefaultTypeFromButton();            // remove type=\"submit\" from button tags \n$htmlMin-\u003edoRemoveEmptyAttributes();                  // remove some empty attributes (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveValueFromEmptyInput();              // remove 'value=\"\"' from empty \u003cinput\u003e (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoSortCssClassNames();                      // sort css-class-names, for better gzip results (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoSortHtmlAttributes();                     // sort html-attributes, for better gzip results (depends on \"doOptimizeAttributes(true)\")\n$htmlMin-\u003edoRemoveSpacesBetweenTags();                // remove more (aggressive) spaces in the dom (disabled by default)\n$htmlMin-\u003edoRemoveOmittedQuotes();                    // remove quotes e.g. class=\"lall\" =\u003e class=lall\n$htmlMin-\u003edoRemoveOmittedHtmlTags();                  // remove ommitted html tags e.g. \u003cp\u003elall\u003c/p\u003e =\u003e \u003cp\u003elall \n```\n\nPS: you can use the \"nocompress\"-tag to keep the html e.g.: \"\u003cnocompress\u003e\\n foobar \\n\u003c/nocompress\u003e\"\n\n### Unit Test\n\n1) [Composer](https://getcomposer.org) is a prerequisite for running the tests.\n\n```\ncomposer require voku/html-min\n```\n\n2) The tests can be executed by running this command from the root directory:\n\n```bash\n./vendor/bin/phpunit\n```\n\n### Support\n\nFor support and donations please visit [Github](https://github.com/voku/HtmlMin/) | [Issues](https://github.com/voku/HtmlMin/issues) | [PayPal](https://paypal.me/moelleken) | [Patreon](https://www.patreon.com/voku).\n\nFor status updates and release announcements please visit [Releases](https://github.com/voku/HtmlMin/releases) | [Twitter](https://twitter.com/suckup_de) | [Patreon](https://www.patreon.com/voku/posts).\n\nFor professional support please contact [me](https://about.me/voku).\n\n### Thanks\n\n- Thanks to [GitHub](https://github.com) (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.\n- Thanks to [IntelliJ](https://www.jetbrains.com) as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!\n- Thanks to [Travis CI](https://travis-ci.com/) for being the most awesome, easiest continous integration tool out there!\n- Thanks to [StyleCI](https://styleci.io/) for the simple but powerful code style check.\n- Thanks to [PHPStan](https://github.com/phpstan/phpstan) \u0026 [Psalm](https://github.com/vimeo/psalm) for really great Static analysis tools and for discovering bugs in the code!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoku%2Fhtmlmin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoku%2Fhtmlmin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoku%2Fhtmlmin/lists"}