WyriHaximus / HtmlCompress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

True is changing to !0

manu-sparheld opened this issue · comments

Hi,

Thanks for nice lib.

So I am using in a project. and I have Google Js in page. After compression it make true to !0.

A similar issue can be find here
https://forum.kuketz-blog.de/viewtopic.php?t=3701

Do you have any solution for it?

Thanks

Hey !0 evaluates to true so to be honest not entirely sure what this is an problem. And since I barely know any German the form post is very clear to me, neither is the automatic translation.

It's a problem because if you have Google analytics 's code on page, and it uses true in script. So if it gets changed to !0, Google do not recognize true any more,

Its an impact on SEO and Google analytics integration. Which is a serious problem in production.

I hope you will consider it's bad impacts.

Thanks

@WyriHaximus,

to describe the problem a bit better I think it is referred to this:

Before compression:
<script>ga('set', 'anonymizeIp', true);</script>

After compression:
<script>ga('set', 'anonymizeIp', !0);</script>

The code comes from Google Analytics. Therefore, no adjustments to it can be made.

Is it possible to exclude partials from compression?

@WyriHaximus,

to describe the problem a bit better I think it is referred to this:

Before compression:
<script>ga('set', 'anonymizeIp', true);</script>

After compression:
<script>ga('set', 'anonymizeIp', !0);</script>

The code comes from Google Analytics. Therefore, no adjustments to it can be made.

!0 evaluates to true (checked both Firefox and Chrome to be sure) so it shouldn't be an issue at all. So when you execute that code the input into ga will be 'set', 'anonymizeIp', true even though the last argument is compressed to !0. Or are you getting results in the wild or warnings from somewhere indicating otherwise?

Is it possible to exclude partials from compression?

Try wrapping it in <nocompress> tags.

Try wrapping it in <nocompress> tags.

This doesn't work. Getting same output. As mentioned above.

Try wrapping it in <nocompress> tags.

This doesn't work. Getting same output. As mentioned above.

Did you look into the other thing I've mentioned? Another way to prevent javascript from getting compressed it to use constructFastest on the Factory.

@manu-sparheld @Kruthaup Still interested to know why this is an issues. Because !0 evaluates to true so it can't be that. Are there some times checking for the specific snippet to be there or some other reason outside of running the code that causes issues?

Because Google do not understand it anyways.

Yeah I get that, but I'm trying to figure out if that's in the browser running the code, or that they're checking for that bit of code on the website in another way causing problems for you. If it's the latter it can be solved in the code by ignoring that specific snippet

@manu-sparheld Which part of Google does not understand the semantically equivalent form? To my understanding Google comes only into contact with that snippet through the Browser JavaScript engine executing it. Therefore it's not an issue for Google.

The linked german forum mentions a bug in a privacy score tool, which must be fixed by the maintainers of the tool. This bug seems to be fixed, according to a post in the forum.

@CharlotteDunois I added snippet in issue already

@WyriHaximus I fixed the "nocompress" problem in the current version of HtmlMin (4.0.5), the problem was that I did not protect "nocompress"-tags before notifying the Observer :/ - voku/HtmlMin@a0f1729

@voku cool thanks! Will have a look at it soon. Also FYI this also seems broken on the previous mayor version so no sweat :)