Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(html/minifier): Merge identical metadata elements (#6183)
- Loading branch information
1 parent
789ea16
commit 41093b0
Showing
17 changed files
with
227 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
crates/swc_html_minifier/tests/fixture/attribute/custom-attribute/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<!doctype html><html lang=en><meta charset=UTF-8><meta name=viewport content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"><title>Document</title><button type=button onclick=a(3) ng-click=a(3) data-click=a(3)></button> | ||
<button type=button onclick=a(3) ng-click=a(3) data-click=a(3)></button> | ||
<div data-json='{"foo":"bar"}'></div> | ||
<div data-json='{"foo":"bar"}'></div> | ||
<div data-json='{"foo":"bar"}'></div> | ||
<div data-style=color:red;background-color:red></div> | ||
<iframe srcdoc="<p>test." src=nosrcdoc.html></iframe> | ||
<div data-html="<p>test." src=nosrcdoc.html></div> |
9 changes: 9 additions & 0 deletions
9
crates/swc_html_minifier/tests/fixture/attribute/srcdoc/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<iframe srcdoc="<p>hello<!-- comment --> </p>"></iframe> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
crates/swc_html_minifier/tests/fixture/attribute/srcdoc/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!doctype html><html lang=en><title>Document</title><iframe srcdoc="<p>hello"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
crates/swc_html_minifier/tests/fixture/element/style-group-1/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"removeEmptyMetadataElements": false | ||
} |
64 changes: 64 additions & 0 deletions
64
crates/swc_html_minifier/tests/fixture/element/style-group-1/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Document</title> | ||
<style> | ||
a { | ||
color:red | ||
} | ||
</style><style> | ||
b { | ||
color:blue | ||
} | ||
</style> | ||
<!-- test --> | ||
<style> | ||
p { | ||
color: white; | ||
background-color: blue; | ||
padding: 5px; | ||
border: 1px solid black; | ||
} | ||
</style> | ||
<style> | ||
p { | ||
color: blue; | ||
background-color: yellow; | ||
} | ||
</style> | ||
<style media="all and (max-width: 500px)"> | ||
p { | ||
color: blue; | ||
background-color: yellow; | ||
} | ||
</style> | ||
<style type="text/css"> | ||
.first { | ||
color: red; | ||
} | ||
</style> | ||
<style type="text/css"> | ||
.second { | ||
color: red; | ||
} | ||
</style> | ||
<style media="all"> | ||
p { | ||
color: blue; | ||
} | ||
</style> | ||
<style media="all"> | ||
p { | ||
color: red; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div>test</div> | ||
<style>a { color: red }</style> | ||
<style></style> | ||
<div>test</div> | ||
<style></style> | ||
<style>a { color: red }</style> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
crates/swc_html_minifier/tests/fixture/element/style-group-1/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!doctype html><html lang=en><title>Document</title><style>a{color:red}b{color:blue}p{color:white;background-color:blue;padding:5px;border:1px solid black}p{color:blue;background-color:yellow}</style><style media="all and (max-width:500px)">p{color:blue;background-color:yellow}</style><style>.first{color:red}.second{color:red}</style><style media=all>p{color:blue}p{color:red}</style><div>test</div> | ||
<style>a{color:red}</style> | ||
<div>test</div> | ||
<style>a{color:red}</style> |
76 changes: 76 additions & 0 deletions
76
crates/swc_html_minifier/tests/fixture/element/style-group/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Document</title> | ||
<style> | ||
a { | ||
color:red | ||
} | ||
</style><style> | ||
b { | ||
color:blue | ||
} | ||
</style> | ||
<!-- test --> | ||
<style> | ||
p { | ||
color: white; | ||
background-color: blue; | ||
padding: 5px; | ||
border: 1px solid black; | ||
} | ||
</style> | ||
<style> | ||
p { | ||
color: blue; | ||
background-color: yellow; | ||
} | ||
</style> | ||
<style media="all and (max-width: 500px)"> | ||
p { | ||
color: blue; | ||
background-color: yellow; | ||
} | ||
</style> | ||
<style type="text/css"> | ||
.first { | ||
color: red; | ||
} | ||
</style> | ||
<style type="text/css"> | ||
.second { | ||
color: red; | ||
} | ||
</style> | ||
<style media="all"> | ||
p { | ||
color: blue; | ||
} | ||
</style> | ||
<style media="all"> | ||
p { | ||
color: red; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Text</h1> | ||
<div>Text</div> | ||
<style> | ||
a { | ||
color:red | ||
} | ||
</style> | ||
<style> | ||
b { | ||
color:blue | ||
} | ||
</style> | ||
<div>test</div> | ||
<style>a { color: red }</style> | ||
<style></style> | ||
<div>test</div> | ||
<style></style> | ||
<style>a { color: red }</style> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
crates/swc_html_minifier/tests/fixture/element/style-group/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!doctype html><html lang=en><title>Document</title><style>a{color:red}b{color:blue}p{color:white;background-color:blue;padding:5px;border:1px solid black}p{color:blue;background-color:yellow}</style><style media="all and (max-width:500px)">p{color:blue;background-color:yellow}</style><style>.first{color:red}.second{color:red}</style><style media=all>p{color:blue}p{color:red}</style><h1>Text</h1> | ||
<div>Text</div> | ||
<style>a{color:red}b{color:blue}</style> | ||
<div>test</div> | ||
<style>a{color:red}</style> | ||
<div>test</div> | ||
|
||
<style>a{color:red}</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41093b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/minify/libraries/antd
1947116812
ns/iter (± 57266737
)1748109688
ns/iter (± 17480335
)1.11
es/full/minify/libraries/d3
415278392
ns/iter (± 27625194
)363397620
ns/iter (± 9193663
)1.14
es/full/minify/libraries/echarts
1618382624
ns/iter (± 56434405
)1481507695
ns/iter (± 10605396
)1.09
es/full/minify/libraries/jquery
101189389
ns/iter (± 6390662
)94386628
ns/iter (± 1680940
)1.07
es/full/minify/libraries/lodash
110837073
ns/iter (± 4895977
)107645520
ns/iter (± 1616422
)1.03
es/full/minify/libraries/moment
58537819
ns/iter (± 1568351
)54794340
ns/iter (± 826143
)1.07
es/full/minify/libraries/react
20076472
ns/iter (± 996483
)18871283
ns/iter (± 366698
)1.06
es/full/minify/libraries/terser
361825615
ns/iter (± 19836127
)283483870
ns/iter (± 7607016
)1.28
es/full/minify/libraries/three
643517767
ns/iter (± 28558633
)524268008
ns/iter (± 13909328
)1.23
es/full/minify/libraries/typescript
3802784919
ns/iter (± 492403221
)3249166309
ns/iter (± 30481272
)1.17
es/full/minify/libraries/victory
912334212
ns/iter (± 54130646
)771717290
ns/iter (± 11779978
)1.18
es/full/minify/libraries/vue
166430808
ns/iter (± 11248521
)134482843
ns/iter (± 2097866
)1.24
es/full/codegen/es3
35187
ns/iter (± 4671
)32981
ns/iter (± 839
)1.07
es/full/codegen/es5
36162
ns/iter (± 5648
)33087
ns/iter (± 1212
)1.09
es/full/codegen/es2015
37473
ns/iter (± 5488
)33131
ns/iter (± 1707
)1.13
es/full/codegen/es2016
38919
ns/iter (± 7237
)32986
ns/iter (± 1043
)1.18
es/full/codegen/es2017
38312
ns/iter (± 7447
)33028
ns/iter (± 586
)1.16
es/full/codegen/es2018
36559
ns/iter (± 5444
)33112
ns/iter (± 410
)1.10
es/full/codegen/es2019
38168
ns/iter (± 5357
)33275
ns/iter (± 587
)1.15
es/full/codegen/es2020
36801
ns/iter (± 5798
)33022
ns/iter (± 991
)1.11
es/full/all/es3
217099922
ns/iter (± 12824230
)183541605
ns/iter (± 3262227
)1.18
es/full/all/es5
214007170
ns/iter (± 20873001
)174501016
ns/iter (± 2897174
)1.23
es/full/all/es2015
170815819
ns/iter (± 24019257
)140091322
ns/iter (± 3273654
)1.22
es/full/all/es2016
164077194
ns/iter (± 15470486
)139238713
ns/iter (± 3080109
)1.18
es/full/all/es2017
160948136
ns/iter (± 9292730
)138780063
ns/iter (± 3019447
)1.16
es/full/all/es2018
162927717
ns/iter (± 12501176
)136903211
ns/iter (± 4037907
)1.19
es/full/all/es2019
166608397
ns/iter (± 25164250
)136341740
ns/iter (± 3855380
)1.22
es/full/all/es2020
183160135
ns/iter (± 26644117
)132001929
ns/iter (± 2968557
)1.39
es/full/parser
875800
ns/iter (± 131697
)690502
ns/iter (± 23773
)1.27
es/full/base/fixer
27390
ns/iter (± 2853
)24856
ns/iter (± 369
)1.10
es/full/base/resolver_and_hygiene
98030
ns/iter (± 8447
)89474
ns/iter (± 1416
)1.10
serialization of ast node
227
ns/iter (± 36
)204
ns/iter (± 5
)1.11
serialization of serde
213
ns/iter (± 21
)219
ns/iter (± 6
)0.97
This comment was automatically generated by workflow using github-action-benchmark.