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): Compress
javascript:
URLs (#6185)
- Loading branch information
1 parent
a81cc9a
commit 8f00d1a
Showing
7 changed files
with
119 additions
and
7 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
3 changes: 3 additions & 0 deletions
3
crates/swc_html_minifier/tests/fixture/attribute/javascript-urls-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 @@ | ||
{ | ||
"normalizeAttributes": false | ||
} |
21 changes: 21 additions & 0 deletions
21
crates/swc_html_minifier/tests/fixture/attribute/javascript-urls-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,21 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<a href=" javascript: alert( 'test' ) ">a</a> | ||
<a href=" JAVASCRIPT: alert( 'test' ) ">b</a> | ||
<iframe src="javascript: alert( 'test' ) " frameborder="0"></iframe> | ||
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<!-- A link around a shape --> | ||
<a href="javascript: alert( 'test' ) "> | ||
<circle cx="50" cy="40" r="35" /> | ||
</a> | ||
<!-- A link around a text --> | ||
<a href=" javascript: alert( 'test' ) "> | ||
<text x="50" y="90" text-anchor="middle"><circle></text> | ||
</a> | ||
</svg> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
crates/swc_html_minifier/tests/fixture/attribute/javascript-urls-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,13 @@ | ||
<!doctype html><html lang=en><title>Document</title><a href='javascript:alert("test")'>a</a> | ||
<a href='javascript:alert("test")'>b</a> | ||
<iframe src='javascript:alert("test")' frameborder=0></iframe> | ||
<svg viewBox="0 0 100 100"> | ||
|
||
<a href='javascript:alert("test")'> | ||
<circle cx=50 cy=40 r=35 /> | ||
</a> | ||
|
||
<a href='javascript:alert("test")'> | ||
<text x=50 y=90 text-anchor=middle><circle></text> | ||
</a> | ||
</svg> |
22 changes: 22 additions & 0 deletions
22
crates/swc_html_minifier/tests/fixture/attribute/javascript-urls/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,22 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<a href=" javascript: alert( 'test' ) ">a</a> | ||
<a href=" JAVASCRIPT: alert( 'test' ) ">b</a> | ||
<a href=" JAVASCRIPT: broken;;( ">b</a> | ||
<iframe src="javascript: alert( 'test' ) " frameborder="0"></iframe> | ||
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<!-- A link around a shape --> | ||
<a href="javascript: alert( 'test' ) "> | ||
<circle cx="50" cy="40" r="35" /> | ||
</a> | ||
<!-- A link around a text --> | ||
<a href=" javascript: alert( 'test' ) "> | ||
<text x="50" y="90" text-anchor="middle"><circle></text> | ||
</a> | ||
</svg> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
crates/swc_html_minifier/tests/fixture/attribute/javascript-urls/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,14 @@ | ||
<!doctype html><html lang=en><title>Document</title><a href='javascript:alert("test")'>a</a> | ||
<a href='javascript:alert("test")'>b</a> | ||
<a href=" JAVASCRIPT: broken;;( ">b</a> | ||
<iframe src='javascript:alert("test")' frameborder=0></iframe> | ||
<svg viewBox="0 0 100 100"> | ||
|
||
<a href='javascript:alert("test")'> | ||
<circle cx=50 cy=40 r=35 /> | ||
</a> | ||
|
||
<a href='javascript:alert("test")'> | ||
<text x=50 y=90 text-anchor=middle><circle></text> | ||
</a> | ||
</svg> |
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
8f00d1a
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
1800709158
ns/iter (± 38890459
)1947116812
ns/iter (± 57266737
)0.92
es/full/minify/libraries/d3
388164960
ns/iter (± 11991389
)415278392
ns/iter (± 27625194
)0.93
es/full/minify/libraries/echarts
1520225719
ns/iter (± 37278534
)1618382624
ns/iter (± 56434405
)0.94
es/full/minify/libraries/jquery
99995648
ns/iter (± 5137842
)101189389
ns/iter (± 6390662
)0.99
es/full/minify/libraries/lodash
110506896
ns/iter (± 8643418
)110837073
ns/iter (± 4895977
)1.00
es/full/minify/libraries/moment
57088122
ns/iter (± 536126
)58537819
ns/iter (± 1568351
)0.98
es/full/minify/libraries/react
19719555
ns/iter (± 1420530
)20076472
ns/iter (± 996483
)0.98
es/full/minify/libraries/terser
314548684
ns/iter (± 12543095
)361825615
ns/iter (± 19836127
)0.87
es/full/minify/libraries/three
564957937
ns/iter (± 107315057
)643517767
ns/iter (± 28558633
)0.88
es/full/minify/libraries/typescript
3396568614
ns/iter (± 57650840
)3802784919
ns/iter (± 492403221
)0.89
es/full/minify/libraries/victory
814522039
ns/iter (± 27780768
)912334212
ns/iter (± 54130646
)0.89
es/full/minify/libraries/vue
152276767
ns/iter (± 9636268
)166430808
ns/iter (± 11248521
)0.91
es/full/codegen/es3
34317
ns/iter (± 551
)35187
ns/iter (± 4671
)0.98
es/full/codegen/es5
34294
ns/iter (± 830
)36162
ns/iter (± 5648
)0.95
es/full/codegen/es2015
34253
ns/iter (± 1570
)37473
ns/iter (± 5488
)0.91
es/full/codegen/es2016
34369
ns/iter (± 680
)38919
ns/iter (± 7237
)0.88
es/full/codegen/es2017
35012
ns/iter (± 2705
)38312
ns/iter (± 7447
)0.91
es/full/codegen/es2018
34676
ns/iter (± 1583
)36559
ns/iter (± 5444
)0.95
es/full/codegen/es2019
34643
ns/iter (± 1861
)38168
ns/iter (± 5357
)0.91
es/full/codegen/es2020
34889
ns/iter (± 2549
)36801
ns/iter (± 5798
)0.95
es/full/all/es3
215058960
ns/iter (± 19691599
)217099922
ns/iter (± 12824230
)0.99
es/full/all/es5
202871274
ns/iter (± 27387408
)214007170
ns/iter (± 20873001
)0.95
es/full/all/es2015
174807699
ns/iter (± 12542677
)170815819
ns/iter (± 24019257
)1.02
es/full/all/es2016
164798007
ns/iter (± 18819019
)164077194
ns/iter (± 15470486
)1.00
es/full/all/es2017
171933400
ns/iter (± 19929431
)160948136
ns/iter (± 9292730
)1.07
es/full/all/es2018
168173052
ns/iter (± 15790482
)162927717
ns/iter (± 12501176
)1.03
es/full/all/es2019
166898599
ns/iter (± 18117798
)166608397
ns/iter (± 25164250
)1.00
es/full/all/es2020
158483321
ns/iter (± 21210884
)183160135
ns/iter (± 26644117
)0.87
es/full/parser
748265
ns/iter (± 124506
)875800
ns/iter (± 131697
)0.85
es/full/base/fixer
27255
ns/iter (± 3657
)27390
ns/iter (± 2853
)1.00
es/full/base/resolver_and_hygiene
97323
ns/iter (± 14006
)98030
ns/iter (± 8447
)0.99
serialization of ast node
213
ns/iter (± 19
)227
ns/iter (± 36
)0.94
serialization of serde
220
ns/iter (± 34
)213
ns/iter (± 21
)1.03
This comment was automatically generated by workflow using github-action-benchmark.