Unable to understand Speed Booster

Posted in: Newspaper
Post count: 74

I tried many times to clear render blocking css and JS but not successful. I hope someone here will help me out.

Here is my speedbooster.php file

<?php
/*
	Plugin Name: tagDiv speed booster
	Plugin URI: http://tagdiv.com
	Description: Speed booster for Newspaper theme - It moves the styles and all the scripts of the theme to the bottom. It also activates internal theme optimizations for better speed.
	Author: tagDiv
	Version: 2.5
	Author URI: http://tagdiv.com
*/

/*
 * 2.6  - fixed rendering bug on the loading of the page
 * 2.5  - code improvements, newspaper 4 compatibility
 *      - makes most of the javascript files use defer parsing
 *      - better compatibility with revolution slider
 * 2.4 - updated jquery version
 *     - support for https
 * 2.3 - fixed warnings when trying to move javascript files that are not registered
 */

class td_speed_booster {

    var $load_contact_form_7 = '';
    var $load_google_fonts = '';

    var $styles_for_footer = array();

    var $async_js_scripts = array(
        'contact-form-7',
        'bbpress',
        'woocommerce',
        'site',
        'devicepx',
        'js_composer_front'
    );

    function __construct() {
        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_hook'), 100);
        add_action('wp_footer', array($this, 'wp_footer_hook'), 15);
        add_action('wp_head', array($this, 'wp_head_hook'), 15);

        define('TD_SPEED_BOOSTER' , 'v2.5');
    }

    function enqueue_scripts_hook() {
        global $wp_scripts;

        //$this->move_js_to_footer('bp-legacy-js');

        //detect revmin - revolution slider and do not move jquery
        if( !is_admin() and !isset($wp_scripts->registered['revmin'])){
            if (is_ssl()) {
                $td_protocol = 'https';
            } else {
                $td_protocol = 'http';
            }

            wp_deregister_script('jquery');
            wp_register_script('jquery', ($td_protocol . '://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'), true, '1.11.0', true);
            wp_enqueue_script('jquery');
        }

        //move styles
        $this->move_style_to_footer('bbp-default-bbpress');  //bpress old
        $this->move_style_to_footer('bbp-default');  //bpress

        $this->move_style_to_footer('contact-form-7');
        $this->move_style_to_footer('td-bootstrap');
        $this->move_style_to_footer('td-theme');

        $this->move_style_to_footer('google-font-rest');
        $this->move_style_to_footer('woocommerce_frontend_styles');

        //jetpack lost styles
        $this->move_style_to_footer('jetpack-subscriptions');
        $this->move_style_to_footer('jetpack-widgets');

        $this->move_js_to_footer('themepunchtools');
        $this->move_js_to_footer('revmin');

        //bbpress
        //remove_action( 'bbp_head', array($BBP_Default, 'head_scripts') );
    }

    function wp_footer_hook() {

        $current_theme_version = '';

        if (defined('TD_THEME_VERSION')) {
            //get the theme version for style
            $current_theme_version = TD_THEME_VERSION;

            //on demo mode, autogenerate version hourly + day
            if (TD_DEPLOY_MODE == 'demo') {
                $current_theme_version = date('jG');
            }
        }

        foreach ($this->styles_for_footer as $style_id => $style_src) {
            echo "<link rel='stylesheet' id='" . $style_id . "-css'  href='" . $style_src . "?ver=" . $current_theme_version . "' type='text/css' media='all' />\n";
        }
    }

    function wp_head_hook() {
        if (defined('TD_THEME_VERSION')) {
            echo '<style>body {visibility:hidden;}</style>';
        }
    }

    function move_style_to_footer($style_id) {
        global $wp_styles;
        if (!empty($wp_styles->registered[$style_id]) and !empty($wp_styles->registered[$style_id]->src)) {
            $this->styles_for_footer[$style_id] = $wp_styles->registered[$style_id]->src;
            wp_deregister_style($style_id);
        }
    }

    function move_js_to_footer($js_id) {
        global $wp_scripts;
        if (isset($wp_scripts->registered[$js_id])) {
            wp_enqueue_script($js_id, ($wp_scripts->registered[$js_id]->src), '', $wp_scripts->registered[$js_id]->ver, true);
        }

    }

    function async_js_hook($url) {

        //check to see if we have js
        if (strpos( $url, '.js' ) === false) {
            return $url;
        }

        if ($this->strpos_array($url, $this->async_js_scripts) === false) {
            return $url;
        } else {
            return "$url' defer='defer";
        }

    }

    private function strpos_array($haystack_string, $needle_array, $offset=0) {
        foreach($needle_array as $query) {
            if(strpos($haystack_string, $query, $offset) !== false) {
                return true; // stop on first true result
            }
        }
        return false;
    }

}

new td_speed_booster();

And here is my function generated file

registered scripts
common | /wp-admin/js/common.min.js
admin-bar | /wp-includes/js/admin-bar.min.js
utils | /wp-includes/js/utils.min.js
svg-painter | /wp-admin/js/svg-painter.js
wp-auth-check | /wp-includes/js/wp-auth-check.min.js
itsec_file_change_warning_js | http://mydomain.com/wp-content/plugins/better-wp-security/modules/free/file-change/js/admin-file-change-warning.js
itsec_strong_passwords | http://mydomain.com/wp-content/plugins/better-wp-security/modules/free/strong-passwords/js/strong-passwords.js
devicepx | http://s0.wp.com/wp-content/js/devicepx-jetpack.js
wpuf-subscriptions | http://mydomain.com/wp-content/plugins/wp-user-frontend-pro/assets/js/subscriptions.js
wp-color-picker | /wp-admin/js/color-picker.min.js
jquery | 
media-upload | /wp-admin/js/media-upload.min.js
thickbox | /wp-includes/js/thickbox/thickbox.js
wpuf-chosen | http://mydomain.com/wp-content/plugins/wp-user-frontend-pro/admin/../assets/js/chosen.jquery.js
wpseo-admin-global-script | http://mydomain.com/wp-content/plugins/wordpress-seo/js/wp-seo-admin-global.min.js
td-wp-admin-general | http://mydomain.com/wp-content/themes/Newspaper/wp-admin/js/general.js
td-wp-admin-panel-js | http://mydomain.com/wp-content/themes/Newspaper/wp-admin/js/wp-admin-panel.js
suggest | /wp-includes/js/jquery/suggest.min.js
registered styles
admin-bar | /wp-includes/css/admin-bar.min.css
colors | 1
ie | /wp-admin/css/ie.min.css
wp-auth-check | /wp-includes/css/wp-auth-check.min.css
itsec_notice_css | http://mydomain.com/wp-content/plugins/better-wp-security/core/css/itsec_notice.css
wp-color-picker | /wp-admin/css/color-picker.min.css
wpuf-chosen-style | http://mydomain.com/wp-content/plugins/wp-user-frontend-pro/admin/../assets/css/chosen/chosen.css
google-font-ubuntu | http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,300italic,400italic,500italic,700italic&subset=latin,cyrillic-ext,greek-ext,greek,latin-ext,cyrillic
td-wp-admin-td-panel-2 | http://mydomain.com/wp-content/themes/Newspaper/wp-admin/css/wp-admin.css
thickbox | /wp-includes/js/thickbox/thickbox.css
wpalchemy-metabox | http://mydomain.com/wp-content/themes/Newspaper/wp-admin/content-metaboxes/meta.css
ithemes-icon-font | http://mydomain.com/wp-content/plugins/better-wp-security/lib/icon-fonts/icon-fonts.css
bbp-admin-css | http://mydomain.com/wp-content/plugins/bbpress/includes/admin/css/admin.css
jetpack-icons | http://mydomain.com/wp-content/plugins/jetpack/_inc/jetpack-icons.min.css

Here what my pagespeed test suggest

Remove Render Blocking Javascript
http://mydomain.com/wp-includes/js/jquery/jquery.js.pagespeed.jm.ocognCjcS2.js

http://mydomain.com/wp-includes/js/jquery/jquery-migrate.min.js.pagespeed.jm.mhpNjdU8Wl.js

http://maps.google.com/maps/api/js?sensor=true

http://maps.gstatic.com/maps-api-v3/api/js/17/15/main.js

http://mydomain.com/wp-content/plugins/wp-user-frontend-pro/assets/js/frontend-form.js.pagespeed.jm.DduuMTRcHs.js

Optimize CSS Deliver of the following

http://mydomain.com/wp-content/plugins/revslider/rs-plugin/css/W.settings.css,qrev=4.3.8.pagespeed.cf.DyIPD1r_80.css

http://mydomain.com/wp-content/plugins/revslider/rs-plugin/css/W.captions.php,qrev=4.3.8.pagespeed.cf.VUw1T7K7S2.css

http://mydomain.com/wp-content/plugins/wp-user-frontend-pro/assets/css/W.frontend-forms.css.pagespeed.cf.vemqQTxrMU.css

http://fonts.googleapis.com/css?family=Roboto%3A400%2C700

I am also using Dreampress which is on varnish cache. I enabled Page Speed Mod as well. No other caching plugin.
My Page Speed Score is 64 for desktop and 41 for mobile.

Further, Here is what i added in my httaccess

<IfModule pagespeed_module>
  ModPagespeed on
  ModPagespeedModifyCachingHeaders off
</IfModule>

# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 604800 seconds"
ExpiresByType image/jpeg "access plus 604800 seconds"
ExpiresByType image/png "access plus 604800 seconds"
ExpiresByType image/gif "access plus 604800 seconds"
ExpiresByType application/x-shockwave-flash "access plus 604800 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
#ExpiresByType text/html "access plus 600 seconds"
#ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers

Now please suggest me what to do for increasing my page speed. My site is damn slow. Please help me to correct the speedbooster.php file as per instructions. Special request ot Christopher for helping me out. Thanks

Post count: 74

Can somebody please setup my speedbooster.php file according to pagespeed as descibed above. It will be really helpful. Thanks

Post count: 74

Still waiting 🙁

Post count: 9544

You might have a wait. Not everybody who is on the forum has time to fix your server for you. Your first chore would be to read through all the posts in the PageSpeed topic where many folks, including myself, have provided a wealth of FREE advice on how to optimize your server, pagespeed, caching, htaccess and set your server settings properly for gzip/deflate, time to live headers, etc.

The “tagdiv speed booster” plugin is only designed to help with issues of loading js and css files in the most efficient manner for the theme; it doesn’t do anything for your server side caching, account speed on the net (response time), gzip/deflate, expiration headers, or image compression. Put another way it’s not a “config file” for your server, it’s preset to speed up the theme, rather seamlessly in most cases. While you can add to it, if you need to have an additional plugin or something “optimized” for loading when theme pages load, it will NOT fix issues on your server or the content you upload.

Advice would be to first optimize your site content such as using GTMetrix to check your site for server side elements which need to be addressed FIRST, then move on to elements which can be addressed via htaccess, optimize images, and the like. Do all your checks with mod_pagespeed off as this caches elements while you’re working on things. Set the tagdiv speed booster last (only edit it if you understand what you’re doing); then when you have a decent setup, then switch on mod_pagespeed.

However, as noted in the PageSpeed topic, gzip/deflate, expires headers, and the like are good for 20 points all alone. Most common issue if your score is below 80 desktop.

Also, remember this forum provides theme support from the developer, not server management support. You need to learn to manage your server and hosting setup, and this is necessary regardless of what theme you run. So, unless you address those issues first, then the elements to fix in WordPress will not be very effective.

I’m sure Marius will be happy to help with questions on the td_speedbooster plugin included with the theme, but you really should read through the PageSpeed topic since I’ve provided a wealth of advice, and how-to elements there which are critical to optimizing your site — including my own mod_pagespeed settings!

  • This reply was modified 11 years by simchris.
Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.