• Resolved misterdude

    (@misterdude)


    Hi Hector,

    I’m getting the following javascript in the head of every page except on index.php & category.php…..

    <!-- WordPress Popular Posts v3.3.1 -->
    				<script type="text/javascript">//<![CDATA[
    
    					var sampling_active = 0;
    					var sampling_rate   = 100;
    					var do_request = false;
    
    					if ( !sampling_active ) {
    						do_request = true;
    					} else {
    						var num = Math.floor(Math.random() * sampling_rate) + 1;
    						do_request = ( 1 === num );
    					}
    
    					if ( do_request ) {
    
    						// Create XMLHttpRequest object and set variables
    						var xhr = ( window.XMLHttpRequest )
    						  ? new XMLHttpRequest()
    						  : new ActiveXObject( "Microsoft.XMLHTTP" ),
    						url = 'http://www.skeletoncrewsc.com/wp-admin/admin-ajax.php',
    						params = 'action=update_views_ajax&token=47096dbc8b&wpp_id=100';
    						// Set request method and target URL
    						xhr.open( "POST", url, true );
    						// Set request header
    						xhr.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
    						// Hook into onreadystatechange
    						xhr.onreadystatechange = function() {
    							if ( 4 === xhr.readyState && 200 === xhr.status ) {
    								if ( window.console && window.console.log ) {
    									window.console.log( xhr.responseText );
    								}
    							}
    						};
    						// Send request
    						xhr.send( params );
    
    					}
    
    				//]]></script>
    				<!-- End WordPress Popular Posts v3.3.1 -->

    Is there any way to remove it? Not sure if it’s needed.

    Kudos on the plugin and the excellent support! 🙂

    Take care

    https://wordpress.org/plugins/wordpress-popular-posts/

Viewing 1 replies (of 1 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    That little script you got there is what updates the views count via AJAX, so it’s actually needed 😛

    It isn’t printed on index.php nor any of the archive templates (category.php, tag.php, archive.php, etc) for performance reasons.

Viewing 1 replies (of 1 total)
  • The topic ‘javascript in head’ is closed to new replies.