You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Valueless crossorigin attribute shouldn't be removed #81
<link crossorigin ...> is equivalent to <link crossorigin="anonymous" ...>, but running that through minify-html results in <link ...>, which is not equivalent.
Without this change, minifying valid HTML written as <link rel="preload" crossorigin ...> will lead to, e.g., opaque preload responses that can't be used. (GoogleChrome/web.dev#7770)
Thanks for raising, I've made the changes into html-data. It turns out the React type definitions that the data is derived from does not consider crossOrigin a boolean attribute, which is why it considers the empty string redundant by default. This may be a bug in the types declaration, or intentional (e.g. force use of empty string). The fix will be part of the next version of minify-html.
I also had a look into the <meta> tag problem mentioned in the same linked issue, but couldn't immediately reproduce it (I quoted around the attribute value as the source input and minify-html did not remove the quotes). I'd be happy to look into it here (or in a new issue) as it does seem unexpected.
in our JavaScript configuration, so I'm not as worried about it.
(As an aside, I see that there's a spec_compliant configuration initializer exposed in the Rust interface, but it's not clear whether the JavaScript bindings' createConfiguration() ends up calling that or not. Is there a difference between calling createConfiguration() with the options supplied above and using the spec_compliant initializer in Rust?)
Awesome, good to hear that the issue is resolved. Version 0.8.1 also fixed the crossorigin attribute handling so it should no longer happen; let me know if it works on your end.
I've now updated the README to mention the options to keep the output spec-compliant more clearly. The spec_compliant method in Rust simply sets those fields in Cfg to true, and keeps the rest at false, so it's the same as providing them explicitly to createConfiguration() as you have described.
Activity
wilsonzlin commentedon Apr 26, 2022
Thanks for raising, I've made the changes into html-data. It turns out the React type definitions that the data is derived from does not consider
crossOrigina boolean attribute, which is why it considers the empty string redundant by default. This may be a bug in the types declaration, or intentional (e.g. force use of empty string). The fix will be part of the next version of minify-html.I also had a look into the
<meta>tag problem mentioned in the same linked issue, but couldn't immediately reproduce it (I quoted around the attribute value as the source input and minify-html did not remove the quotes). I'd be happy to look into it here (or in a new issue) as it does seem unexpected.jeffposnick commentedon Apr 26, 2022
I was able to resolve the
<meta>tag problem by opting-in toin our JavaScript configuration, so I'm not as worried about it.
(As an aside, I see that there's a
spec_compliantconfiguration initializer exposed in the Rust interface, but it's not clear whether the JavaScript bindings'createConfiguration()ends up calling that or not. Is there a difference between callingcreateConfiguration()with the options supplied above and using thespec_compliantinitializer in Rust?)wilsonzlin commentedon Jun 21, 2022
Awesome, good to hear that the issue is resolved. Version
0.8.1also fixed thecrossoriginattribute handling so it should no longer happen; let me know if it works on your end.I've now updated the README to mention the options to keep the output spec-compliant more clearly. The
spec_compliantmethod in Rust simply sets those fields inCfgto true, and keeps the rest atfalse, so it's the same as providing them explicitly tocreateConfiguration()as you have described.