Page Speed Bullshit!

For a page template just so you can see what’s going on


<?php 
	   // template name: styles control 
	    
	    global $wp_styles;

	    
	foreach ($wp_styles->registered as $handle => $data)
	{

		$siteurl = site_url().'/';
		$this_src = str_replace($siteurl,"",$data->src); 
		
		echo htmlentities('<style><?php include \''.ABSPATH.$this_src.'\'; ?></style>'); echo " <br />"; 
		

                //echo $this_src; echo $data->src; echo "-------------------> $handle <br />"; 
        
		// otherwise remove it
		wp_deregister_style($handle);
		wp_dequeue_style($handle);
	}

Defer all scripts

function js_async_attr($tag){

# Add async to all remaining scripts
return str_replace( ' src', " defer='defer' src", $tag );
}
add_filter( 'script_loader_tag', 'js_async_attr', 10 );

For the functions file. Dequeue ALL styles and ‘defer’ all scripts

/*function to add async to all scripts*/
function js_async_attr($tag){

# Add async to all remaining scripts
return str_replace( ' src', ' defer="defer" src', $tag );
}
add_filter( 'script_loader_tag', 'js_async_attr', 10 );






function stop_all_styles() {
	    global $wp_styles;

	    
	foreach ($wp_styles->registered as $handle => $data)
	{
		 //wp_deregister_style($handle);
		 //wp_dequeue_style($handle);
	}
}
add_action( 'wp_print_styles', 'stop_all_styles' );

Edited

function stop_all_styles() {
	    global $wp_styles;

	    
	foreach ($wp_styles->registered as $handle => $data)
	{
		$siteurl = site_url().'/';
		$this_src = str_replace($siteurl,"",$data->src); 
		echo htmlentities('<style><?php include \''.ABSPATH.$this_src.'\'; ?></style>'); echo " -------------------> $handle <br />";
		 wp_deregister_style($handle);
		 wp_dequeue_style($handle);
	}
}
add_action( 'wp_print_styles', 'stop_all_styles' );

If you are really desperate … grab the entire header output and modify it

function start_wp_head_buffer() {
    ob_start();
}
add_action('wp_head','start_wp_head_buffer',0);

function end_wp_head_buffer() {
    $in = ob_get_clean();

    // here do whatever you want with the header code
    echo $in; // output the result unless you want to remove it
}
add_action('wp_head','end_wp_head_buffer',998);

You can try this … put this is functions

function stop_all_styles() {
        global $wp_styles;
        global $inline_styles;
        global $called_styles;
        $siteurl = site_url().'/';
         
    foreach ($wp_styles->registered as $handle => $data)
    {
         if (strpos($data->src,"wp-content") || strpos($data->src,"wp-includes") || strpos($data->src,"wp-admin")) {
		     $cleaned = ABSPATH.str_replace($siteurl,"",$data->src); 
		     $cleaned = str_replace('//clubfitness.staging.wpengine.com',"",$cleaned);
		     $inline_styles[] = $cleaned;
         }else{
	         $called_styles[] = $data->src;
         }  
         


         wp_deregister_style($handle);
         wp_dequeue_style($handle);
    }
    

}
add_action( 'wp_print_styles', 'stop_all_styles' );	

You can try this … put this is footer

<?php global $inline_styles; global $called_styles; ?>

        <?php 
        foreach($inline_styles as $style) { ?>
	        <style><?php include "$style"; ?></style>
       <?php } ?> 

Browser Caching htaccess

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
Comments