WebMarkupMin
WebMarkupMin copied to clipboard
Minification breaks down all my page javascript?
Hello, please check my site.. when i use your tool on other sites its working fine. but minification on this site is causing all the body script tags to not work properly. weird issue is this , i just stops working, but in console i cant see any js related errors.
here is unminified code working fine : newspanda-home
here is the issue when i enable minification : minify-issue here my javascripts in body tags are gone :(
here is my general settings that i tried and failed to mitigate the issue:
new HtmlMinificationSettings()
{
PreserveCase = true,
RemoveHtmlComments = false,
PreservableAttributeList= "form[method=get i], input[type], [xmlns], button[type]",
RemoveEmptyAttributes=false,
AttributeQuotesRemovalMode= HtmlAttributeQuotesRemovalMode.KeepQuotes,
RemoveHttpsProtocolFromAttributes=true,
RemoveHttpProtocolFromAttributes=true,
RemoveHtmlCommentsFromScriptsAndStyles=false,
RemoveJsProtocolFromAttributes=false,
RemoveCssTypeAttributes=false,
RemoveJsTypeAttributes=false,
MinifyInlineJsCode=false,
MinifyEmbeddedJsCode=false,
MinifyEmbeddedCssCode=true,
MinifyEmbeddedJsonData=true,
WhitespaceMinificationMode=WhitespaceMinificationMode.Safe,
MinifyInlineCssCode=true,
}
i am using asp.net core 5 webmarkupmin core 2.9.0 packages i have disabled caching, so you can check live pages repsonse.
Hello, Alok!
Error occurs when processing a script tags with the text/lazyhtml type:
<script type="text/lazyhtml">
<!--
<ins class="adsbygoogle"
style="display:block"
data-ad-format="fluid"
data-ad-layout-key="-fo-26-3s-9h+197"
data-ad-client="ca-pub-2382531196995443"
data-ad-slot="3540637640"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
-->
</script>
HTML parser cannot correctly process nested script tags. As a result, the last end script tag disappears:
<script type=text/lazyhtml>
<!--
<ins class="adsbygoogle"
style="display:block"
data-ad-format="fluid"
data-ad-layout-key="-fo-26-3s-9h+197"
data-ad-client="ca-pub-2382531196995443"
data-ad-slot="3540637640"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
-->
Almost all HTML minifiers I know also cannot correctly process such code. It will not be possible to fix this error quickly, so I recommend that you wrap script tags with the text/lazyhtml type in the ignoring comments:
<!--wmm:ignore-->
<script type="text/lazyhtml">
…
</script>
<!--/wmm:ignore-->
It may also be necessary to disable removing of the onvisible attributes.
ok, no issues i can do that for now... so <!--wmm:ignore--> everywhere i have special tags? will future versions have this capability (i am ok even if they dont). will try and let you know results.
Yes, I will try to fix this problem by the next release.
But for a while, you'll have to use the ignoring comments.