HtmlCompress icon indicating copy to clipboard operation
HtmlCompress copied to clipboard

True is changing to !0

Open manu-sparheld opened this issue 6 years ago • 13 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

manu-sparheld avatar Jun 21 '19 05:06 manu-sparheld

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.

WyriHaximus avatar Jun 22 '19 18:06 WyriHaximus

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

manu-sparheld avatar Jun 24 '19 08:06 manu-sparheld

@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?

Kruthaup avatar Jun 24 '19 09:06 Kruthaup

@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.

WyriHaximus avatar Jun 24 '19 10:06 WyriHaximus

Try wrapping it in <nocompress> tags.

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

manu-sparheld avatar Jun 24 '19 10:06 manu-sparheld

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.

WyriHaximus avatar Jun 24 '19 15:06 WyriHaximus

@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?

WyriHaximus avatar Jul 07 '19 22:07 WyriHaximus

Because Google do not understand it anyways.

manu-sparheld avatar Jul 10 '19 07:07 manu-sparheld

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

WyriHaximus avatar Jul 11 '19 09:07 WyriHaximus

@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.

ghost avatar Sep 01 '19 18:09 ghost

@CharlotteDunois I added snippet in issue already

manu-sparheld avatar Sep 02 '19 07:09 manu-sparheld

@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 :/ - https://github.com/voku/HtmlMin/commit/a0f172923f4e8ec1d0cb08f7d21b51e6e89a1396

voku avatar Sep 19 '19 00:09 voku

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

WyriHaximus avatar Sep 19 '19 06:09 WyriHaximus