javascript - How to Minify Google AdSense JS? - Stack Overflow

Whenever I minify the AdSense script I got from Google, it stops working. Any ideas why?Original Code:&

Whenever I minify the AdSense script I got from Google, it stops working. Any ideas why?

Original Code:

<script type="text/javascript"><!--
google_ad_client = "xxx";
/* Ad 1 */
google_ad_slot = "2668798369";
google_ad_width = 160;
google_ad_height = 600;
//-->

</script>
<script type="text/javascript"
src=".js">

Minified Code:

<script type="text/javascript"><!--google_ad_client = "xxx";/* Ad 1 */google_ad_slot = "2338787596";google_ad_width = 200;google_ad_height = 200;//--></script><script type="text/javascript"src=".js"></script>

The minification is being done by Smarty's {strip} tags.

Whenever I minify the AdSense script I got from Google, it stops working. Any ideas why?

Original Code:

<script type="text/javascript"><!--
google_ad_client = "xxx";
/* Ad 1 */
google_ad_slot = "2668798369";
google_ad_width = 160;
google_ad_height = 600;
//-->

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

Minified Code:

<script type="text/javascript"><!--google_ad_client = "xxx";/* Ad 1 */google_ad_slot = "2338787596";google_ad_width = 200;google_ad_height = 200;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication./pagead/show_ads.js"></script>

The minification is being done by Smarty's {strip} tags.

Share Improve this question edited Feb 2, 2011 at 19:15 StackOverflowNewbie asked Feb 2, 2011 at 19:08 StackOverflowNewbieStackOverflowNewbie 40.7k114 gold badges290 silver badges452 bronze badges 1
  • You probably can't do this as google says you can't change the ads code itself. – justyy Commented Aug 21, 2014 at 14:58
Add a ment  | 

5 Answers 5

Reset to default 2

The problem is the HTML ment tags at the start and end of the first script tag. You don't need them, they're just there to work around Netscape 1.0

Try replacing your minified script with this

<script type="text/javascript">google_ad_client="xxx";google_ad_slot="2668798369";google_ad_width=160;google_ad_height=600;</script><script type="text/javascript"src="http://pagead2.googlesyndication./pagead/show_ads.js">

i think you left out this part:

//-->

Try to remove the <!--

Hope it helps

It'll be the <!-- - this can mean 'treat this line as a ment'. It's an old patibility hack for browers that didn't support JavaScript.

Either remove it or add a linebreak afterwards, i.e.

<script type="text/javascript"><!--
google_ad_client="xxx"; ...

though I can't see what minifying here is gaining you - there's nothing that can be renamed or pressed.

Look out for this:

<!-- and -->

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745452623a4628340.html

相关推荐

  • javascript - How to Minify Google AdSense JS? - Stack Overflow

    Whenever I minify the AdSense script I got from Google, it stops working. Any ideas why?Original Code:&

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信