Google webfonts preventing from getting a good page speed score

  • Raj

    #8062

    Hi

    I have an issue with Google webfonts that prevents me getting good page speed score. Since Google font is an external resource, local apache settings do not have a hand to solve the issue. However, had I been able to remove/disable Google fonts, I would have moved ahead one or two notches on page speed, close to 100. I don’t use Google fonts; instead I use Verdana. I am reproducing the suggestions below by Firebug/Page Speed for your reference. I welcome your suggestions to overcome this hiccup either by disabling/removing Google fonts or serving fonts from our server if possible, preferably the first one.

    â–¾

    Leverage browser caching

    The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

    http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js (1 hour)

    [Score: 83/100]

    â–¾

    Specify a cache validator

    The following resources are missing a cache validator. Resources that do not specify a cache validator cannot be refreshed efficiently. Specify a Last-Modified or ETag header to enable cache validation for the following resources:

    http://fonts.googleapis.com/css?family=Pontano+Sans&subset=latin,latin-ext

    [Score: 96/100]

    â–¾

    Minify JavaScript

    Minifying the following JavaScript resources could reduce their size by 397B (3% reduction).

    Minifying http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js could save 397B (3% reduction) after compression. See optimized version or Save as.

    [Score: 98/100]

    Raj

    #40215

    So, this is a ghost forum! I didn’t know that. Anyway, I removed the code that calls the webfont, and I have a page speed score of 100/100 now.

    Let me hope anybody in need in a similar situation gets this message.

    Prasanna SP

    #40216

    Add this to child theme functions.php to remove Google webfonts.

    function graphene_remove_google_webfonts(){
    remove_action( 'wp_head', 'graphene_webfont_script', 5 );
    remove_action( 'admin_head-appearance_page_custom-header', 'graphene_webfont_script' );
    }
    add_action( 'init', 'graphene_remove_google_webfonts' );

    Raj

    #40217

    However, the child theme breaks the site! Here is the warning message:

    function graphene_remove_google_webfonts(){ remove_action( ‘wp_head’, ‘graphene_webfont_script’, 5 ); remove_action( ‘admin_head-appearance_page_custom-header’, ‘graphene_webfont_script’ ); } add_action( ‘init’, ‘graphene_remove_google_webfonts’ );

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/example/public_html/blog/wp-content/themes/graphene-child/functions.php:12) in /home/example/public_html/blog/wp-content/plugins/si-contact-form/si-contact-form.php on line 1950

    Raj

    #40219

    Prasanna,

    I’m wondering if WP-Minify is optimizing the code even before functions.php of the child theme is pulled in.

    Prasanna SP

    #40220

    Did you put that code after opening php tag, i.e <?php

    <?php
    function graphene_remove_google_webfonts(){
    remove_action( 'wp_head', 'graphene_webfont_script', 5 );
    remove_action( 'admin_head-appearance_page_custom-header', 'graphene_webfont_script' );
    }
    add_action( 'init', 'graphene_remove_google_webfonts' );

    Raj

    #40221

    Oh, how numb I was!

    I missed that. Now it is working fine, and my page speed score with the child theme is also 100/100.

    However, Prasanna, I have another problem too. The following code gets minified with WP-Minify, and autosearch is not working on a 404 page:

    <script type="text/javascript">

    jQuery(document).ready(function($){

    window.location.replace( "<?php echo $redirect_location; ?>" );

    });

    </script>

    Can you please help me regarding this?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.