Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Compressor/HtmlCompressor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class HtmlCompressor implements CompressorInterface
public function __construct(Patterns $patterns)
{
$this->htmlMin = new HtmlMin();
$this->htmlMin->doRemoveSpacesBetweenTags(true);
$this->htmlMin->attachObserverToTheDomLoop(new HtmlMinObserver($patterns));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Compressor/HtmlCompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function providerMultipleSpaces(): iterable

yield [
"<html>\n <head> </head>\n <body>\n <p id=\"text\" class=\"foo\">\n foo\n </p> <br /> <ul > <li> <p class=\"foo\">lall</p> </li></ul>\n </body>\n </html>",
'<html><head> <body><p class=foo id=text> foo </p> <br> <ul><li><p class=foo>lall </ul>',
'<html><head><body><p class=foo id=text> foo </p><br><ul><li><p class=foo>lall </ul>',
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/EdgeCases/WyriHaximus-MinifyHtml-5/out.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><link href=/css/style.css?1453088025 rel=stylesheet> <body><header><nav></nav> </header>
<!DOCTYPE html><html><head><link href=/css/style.css?1453088025 rel=stylesheet><body><header><nav></nav></header>
2 changes: 1 addition & 1 deletion tests/EdgeCases/asciinema/out.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

$socket-&gt;listen(1337);
$loop-&gt;run();
</code></pre> <script async id=asciicast-18487 src=https://asciinema.org/a/18487.js></script>
</code></pre><script async id=asciicast-18487 src=https://asciinema.org/a/18487.js></script>
2 changes: 1 addition & 1 deletion tests/EdgeCases/blog.wyrihaximus.net/out.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><body class=blog><header><nav></nav></header><script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
7 changes: 7 additions & 0 deletions tests/EdgeCases/conditionals/in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<!--[if IE]>
<h1>Hello World</h1>
<![endif]-->
</body>
</html>
1 change: 1 addition & 0 deletions tests/EdgeCases/conditionals/out.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><body><!--[if IE]><h1>Hello World</h1><![endif]-->
2 changes: 1 addition & 1 deletion tests/EdgeCases/ld-json-37/out.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"https:\/\/schema.org\/","@graph":[{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Home","@id":"http:\/\/domain.com"}},{"@type":"ListItem","position":2,"item":{"name":"Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/"}},{"@type":"ListItem","position":3,"item":{"name":"Sub Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/sub-category-name\/"}}]},{"@context":"https:\/\/schema.org\/","@graph":[{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-potiron\/","name":"Mijot\u00e9e de potiron","url":"http:\/\/domain.com\/product\/mijote-de-potiron\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/","name":"Mijot\u00e9e de haricot vert","url":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/","name":"Mijot\u00e9e de carotte","url":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/","name":"Mijot\u00e9e de petit pois","url":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/","name":"Mijot\u00e9e de patate douce","url":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/","name":"Mijot\u00e9e de brocoli","url":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/"}]}]}</script> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"https:\/\/schema.org\/","@graph":[{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Home","@id":"http:\/\/domain.com"}},{"@type":"ListItem","position":2,"item":{"name":"Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/"}},{"@type":"ListItem","position":3,"item":{"name":"Sub Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/sub-category-name\/"}}]},{"@context":"https:\/\/schema.org\/","@graph":[{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-potiron\/","name":"Mijot\u00e9e de potiron","url":"http:\/\/domain.com\/product\/mijote-de-potiron\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/","name":"Mijot\u00e9e de haricot vert","url":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/","name":"Mijot\u00e9e de carotte","url":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/","name":"Mijot\u00e9e de petit pois","url":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/","name":"Mijot\u00e9e de patate douce","url":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/","name":"Mijot\u00e9e de brocoli","url":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/"}]}]}</script><body class=blog><header><nav></nav></header><script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
2 changes: 1 addition & 1 deletion tests/EdgeCases/ld-json/out.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script><body class=blog><header><nav></nav></header><script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
2 changes: 1 addition & 1 deletion tests/Factory/fastest/out.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>/** quick fix because bootstrap <pre> has a background-color. */
pre code { background-color: inherit; }</style> <body class=blog><header><nav></nav> </header> <script>window.jQuery || document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>');
pre code { background-color: inherit; }</style><body class=blog><header><nav></nav></header><script>window.jQuery || document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>');
alert('hoi');</script>
4 changes: 2 additions & 2 deletions tests/Factory/normal/out.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style rng=/dev/null rsync=off>pre code{background-color:inherit}</style> <body class=blog style=background-color:red><header><nav></nav> </header> <script>alert('hoi')</script> <hr> <script rng=/dev/null rsync=off>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script> <hr> <script rng=/dev/null rsync=off>alert('hoi')</script> <hr> <script rng=/dev/null type=language/dutch>Goede morgen,
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style rng=/dev/null rsync=off>pre code{background-color:inherit}</style><body class=blog style=background-color:red><header><nav></nav></header><script>alert('hoi')</script><hr><script rng=/dev/null rsync=off>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script><hr><script rng=/dev/null rsync=off>alert('hoi')</script><hr><script rng=/dev/null type=language/dutch>Goede morgen,
Goede middag,
Goede avond</script> <hr> <script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script>
Goede avond</script><hr><script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script>
4 changes: 2 additions & 2 deletions tests/Factory/smallest/out.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style rng=/dev/null rsync=off>pre code{background-color:inherit}</style> <body class=blog style=background-color:red><header><nav></nav> </header> <script>alert('hoi')</script> <hr> <script rng=/dev/null rsync=off>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script> <hr> <script rng=/dev/null rsync=off>alert('hoi')</script> <hr> <script rng=/dev/null type=language/dutch>Goede morgen,
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style rng=/dev/null rsync=off>pre code{background-color:inherit}</style><body class=blog style=background-color:red><header><nav></nav></header><script>alert('hoi')</script><hr><script rng=/dev/null rsync=off>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script><hr><script rng=/dev/null rsync=off>alert('hoi')</script><hr><script rng=/dev/null type=language/dutch>Goede morgen,
Goede middag,
Goede avond</script> <hr> <script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script>
Goede avond</script><hr><script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script>