Account Options

  1. Sign in
Google Groups Home
« Groups Home
Minify removes adsense comment
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
i...@kinder-aktuell.de  
View profile  
 More options Mar 15 2009, 10:11 am
From: i...@kinder-aktuell.de
Date: Sun, 15 Mar 2009 07:11:19 -0700 (PDT)
Local: Sun, Mar 15 2009 10:11 am
Subject: Minify removes adsense comment
hi,

minify removes the adsense comment. problem: the ads are not shown!

original:
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxx";
google_ad_slot = "xxxxx";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

minified:
<script type="text/javascript"></script> <script type="text/
javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></
script>

does someone know a solution for this?

best wishes
kia


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 15 2009, 10:20 am
From: Steve Clay <st...@mrclay.org>
Date: Sun, 15 Mar 2009 10:20:03 -0400
Local: Sun, Mar 15 2009 10:20 am
Subject: Re: [minify] Minify removes adsense comment

This looks like a bug. Can you remove the HTML comment tokens and see
what you get? In other words:

<script type="text/javascript">
google_ad_client = "pub-xxxxxxxxxxx";
google_ad_slot = "xxxxx";
google_ad_width = 468;
google_ad_height = 60;
</script>

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
i...@kinder-aktuell.de  
View profile  
 More options Mar 15 2009, 10:29 am
From: i...@kinder-aktuell.de
Date: Sun, 15 Mar 2009 07:29:28 -0700 (PDT)
Local: Sun, Mar 15 2009 10:29 am
Subject: Re: Minify removes adsense comment
hi steve,

same output and no comments shown. if i disable minify the vars
between html comments are shown.

On Mar 15, 3:20 pm, Steve Clay <st...@mrclay.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 15 2009, 10:33 am
From: Steve Clay <st...@mrclay.org>
Date: Sun, 15 Mar 2009 10:33:27 -0400
Local: Sun, Mar 15 2009 10:33 am
Subject: Re: [minify] Re: Minify removes adsense comment

i...@kinder-aktuell.de wrote:
> hi steve,

> same output and no comments shown. if i disable minify the vars
> between html comments are shown.

Are you setting the 'jsMinifier' option for HTML?
http://code.google.com/p/minify/source/browse/trunk/min/lib/Minify/HT...

Perhaps that function is to blame. I'm creating a test case now, but may
not be able to report back for several hours.

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 15 2009, 10:43 am
From: Steve Clay <st...@mrclay.org>
Date: Sun, 15 Mar 2009 10:43:16 -0400
Local: Sun, Mar 15 2009 10:43 am
Subject: Re: [minify] Minify removes adsense comment
I think there might be a bug in your code. I added this to my test HTML
file:

> <script type="text/javascript"><!--
> google_ad_client = "pub-xxxxxxxxxxx";
> google_ad_slot = "xxxxx";
> google_ad_width = 468;
> google_ad_height = 60;
> //-->
> </script>

Minify_HTML::minify($src) output:

<script type="text/javascript">google_ad_client = "pub-xxxxxxxxxxx";
google_ad_slot = "xxxxx";
google_ad_width = 468;
google_ad_height = 60;</script>

Output of: Minify_HTML::minify($src, array(
     'jsMinifier' => array('Minify_Javascript', 'minify')
));

<script
type="text/javascript">google_ad_client="pub-xxxxxxxxxxx";google_ad_slot="x xxxx";google_ad_width=468;google_ad_height=60;</script>

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
i...@kinder-aktuell.de  
View profile  
 More options Mar 15 2009, 10:47 am
From: i...@kinder-aktuell.de
Date: Sun, 15 Mar 2009 07:47:12 -0700 (PDT)
Local: Sun, Mar 15 2009 10:47 am
Subject: Re: Minify removes adsense comment
sorry, i dont know.

i use wordpress with wp-super-cache plugin and this mod for wp-super-
cache: http://lyncd.com/2008/11/minify-for-wordpress/
seems like its just for html not for css/js.

wp-super-cache works, minify too, have just the problem with adsense.

On Mar 15, 3:33 pm, Steve Clay <st...@mrclay.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 15 2009, 1:32 pm
From: Steve Clay <st...@mrclay.org>
Date: Sun, 15 Mar 2009 13:32:40 -0400
Local: Sun, Mar 15 2009 1:32 pm
Subject: Re: [minify] Re: Minify removes adsense comment

i...@kinder-aktuell.de wrote:
> sorry, i dont know.

> i use wordpress with wp-super-cache plugin and this mod for wp-super-
> cache: http://lyncd.com/2008/11/minify-for-wordpress/

Hmm, is your PHP version < 5.2.3 ? If so you'll need to edit the file
WPSCMin.php

Starting at line 63, replace:

$html = Minify_HTML::minify($html,
    array('cssMinifier' => 'Minify_CSS::minify',
          'jsMinifier' => 'JSMin::minify'));

with:

$html = Minify_HTML::minify($html,
    array('cssMinifier' => array('Minify_CSS', 'minify'),
          'jsMinifier' => array('JSMin', 'minify')));

PHP before 5.2.3 did not support the static callback syntax that's being
used.

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 15 2009, 5:07 pm
From: Steve Clay <st...@mrclay.org>
Date: Sun, 15 Mar 2009 17:07:12 -0400
Local: Sun, Mar 15 2009 5:07 pm
Subject: Re: [minify] Re: Minify removes adsense comment

i...@kinder-aktuell.de wrote:
> but i read 10 minutes ago thats not allowed to change the google
> adsense code (the html comment is removed). see:
> https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=66096

I don't think whitespace removal would get you punished, but if the
client code *has* to be preserved, here are two functions to add to the
WPSCMin class in WPSCMin.php (jsmin + a replacement for minify):

   public static function jsmin($js) {
     // if has google client code, don't minify
     return (false !== strpos($js, 'google_ad_client'))
       ? trim($js)
       : JSMin::minify($js);
   }

   // Minifies string referenced by $html, if $this->enabled is TRUE
   public function minify(& $html) {
     if (!$this->enabled)
       return;

     // Include Minify components unless they have already been required
     if (!class_exists('Minify_HTML')) {
       require('min/lib/Minify/HTML.php');
       ini_set('include_path',
ini_get('include_path').':'.dirname(__FILE__).'/min/lib');
       require('min/lib/Minify/CSS.php');
       require('min/lib/JSMin.php');
     }

     $html = Minify_HTML::minify($html,
              array('cssMinifier' => array('Minify_CSS', 'minify'),
                    'jsMinifier' => array('WPSCMin', 'jsmin')));
   }

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kia  
View profile  
 More options Mar 15 2009, 6:38 pm
From: kia <i...@kinder-aktuell.de>
Date: Sun, 15 Mar 2009 15:38:13 -0700 (PDT)
Local: Sun, Mar 15 2009 6:38 pm
Subject: Re: Minify removes adsense comment
works well. steve, i dont want to bother you but one last thing.

now its this:
<script type="text/javascript">google_ad_client = "pub-xxxxxx";
/* 468x60, Erstellt 08.03.09 */
google_ad_slot = "xxxxx";
google_ad_width = 468;
google_ad_height = 60;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></
script>

but the original adsense code looks like this:
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxx";
/* 468x60, Erstellt 08.03.09 */
google_ad_slot = "xxxxx";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

its about the missing html comments <!-- and --> in google ads (not
comments generally). its possible to skip them/dont minify them?

or better: its possible to mark code-parts which should not be
minified?

thank you very much.

On Mar 15, 11:28 pm, kia <i...@kinder-aktuell.de> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 15 2009, 9:47 pm
From: Steve Clay <st...@mrclay.org>
Date: Sun, 15 Mar 2009 21:47:31 -0400
Local: Sun, Mar 15 2009 9:47 pm
Subject: Re: [minify] Re: Minify removes adsense comment

kia wrote:
> its about the missing html comments <!-- and --> in google ads (not
> comments generally). its possible to skip them/dont minify them?

(Sigh) due to an annoying PHP5 feature preventing subclassing
Minify_HTML (static methods always bind "self" to the defining class),
you'll actually have to edit Minify/HTML.php directly to do what you want:

1. Find the method _removeScriptCB (line 184)

2. Insert the following at the very beginning of the code (line 186):

         if (false !== strpos($m[3], 'google_ad_client')) {
             // only trim whitespace outside the script tags
             return self::_reservePlace(trim($m[0]));
         }

Since this bypasses JSMin, you can remove the hacking we did to WPSCMin.php

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel.ha...@gmail.com  
View profile  
 More options Mar 16 2009, 4:20 am
From: joel.ha...@gmail.com
Date: Mon, 16 Mar 2009 01:20:28 -0700 (PDT)
Local: Mon, Mar 16 2009 4:20 am
Subject: Re: Minify removes adsense comment
Hi all--

I'm the author of the WPSCMin mod ... just wanted to let you know I'm
going to put out a new version with the older callback syntax in it,
as Steve suggests. Also, I'll test against the 0.9.1 WP Super Cache
that came out a week or two ago and make sure everything still works.

And since Steve was so helpful to find this bug, I'll chime in on the
Adsense question since I've done a lot of work on this and know some
people at Google (I'm north of SF). Google absolutely does not care if
you remove the HTML or JS comments from their code block (I think the
Q&A linked https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=66096
pretty much says that). They mostly care about things that actually
change the content/functionality of the ads, people clicking their own
ads, clickfarms etc. They also don't want to have to provide HTML help
to millions of people, so they just say "don't change the code" a lot.
But you can add/edit/delete comments and whitespace all you want, just
understand you're the one responsible if you break something.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Clay  
View profile  
 More options Mar 16 2009, 8:03 am
From: Steve Clay <st...@mrclay.org>
Date: Mon, 16 Mar 2009 08:03:50 -0400
Local: Mon, Mar 16 2009 8:03 am
Subject: Re: [minify] Re: Minify removes adsense comment

joel.ha...@gmail.com wrote:
> I'm the author of the WPSCMin mod ... just wanted to let you know I'm
> going to put out a new version with the older callback syntax in it,

Thanks, Joel. Feel free to refer markup output bugs to this list. In the
meantime I'm going to make the Minify_HTML class easier to extend so
users can change its behavior. In that light having a way to change the
HTML minifier without modifying WPSCMin.php might be nice eventually.

> people at Google (I'm north of SF). Google absolutely does not care if
> you remove the HTML or JS comments from their code block (I think the

I figured as much, but I also suspect there may be orgs that *do* rely
on specific HTML/JS comments and Minify_HTML should be flexible enough
to allow that.

Thanks for the follow-up.

--
Steve Clay
http://mrclay.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kia  
View profile  
 More options Mar 16 2009, 1:42 pm
From: kia <i...@kinder-aktuell.de>
Date: Mon, 16 Mar 2009 10:42:16 -0700 (PDT)
Local: Mon, Mar 16 2009 1:42 pm
Subject: Re: Minify removes adsense comment
Thank you very much. Works fine now :-)

On Mar 16, 1:03 pm, Steve Clay <st...@mrclay.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »