开发者

How to Minify Google AdSense JS?

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.com/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开发者_如何学JAVA><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

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


The problem is the HTML comment 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.com/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 comment'. It's an old compatibility 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 compressed.


Look out for this:

<!-- and -->

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜