Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There is an extra set of script tags getting spit out currently. There is no longer the need to wrap the GA code within script tag markup. The drupal_pre_render_scripts function now handles this.
Current:
<script>
<!--//--><![CDATA[//><!--
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
//--><!]]>
</script>
Expected:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//--><!]]>
</script>
drupal_pre_render_scripts()
http://api.drupal.org/api/drupal/core!includes!common.inc/function/drupa...
Comment | File | Size | Author |
---|---|---|---|
#2 | 1957432-2-remove-extraneous-script-tag.patch | 1.48 KB | desmondmorris |
Comments
Comment #1
desmondmorris CreditAttribution: desmondmorris commentedHere is the patch. I also added the attributes option to the drupal_add_js function call to include the type attribute to the script tag. Though, it looks like the attributes option is not quite working as expected (http://drupal.org/node/1664602)
Comment #2
desmondmorris CreditAttribution: desmondmorris commentedArgh, I always forget the attachement
Comment #3
frobcommited
Comment #4.0
(not verified) CreditAttribution: commentedspacing