WordPress and PageSpeed Insights

Today i tested my WordPress Theme on Google’s PageSpeed Insights. The result was a little disapointing. The Desktop version scored above 90 out of 100, but the mobile version scored around 80.

Based on Google’s suggestions i searched for some solutions.

Eliminate render-blocking JavaScript and CSS in above-the-fold content

Due to my own plugin Wp Defer loading there was no render-blocking JavaScript.

@import CSS child theme

My test site runs a child theme of JBST. The stylesheet of this child theme imports the stylesheet of it’s parent by @import url(../jamedo-bootstrap-start-theme/style.css);. Although appropriate course of action following Child Themes this is a performance issue.

In the case of JBST the parent style.css contains only some empty default styles. So for child themes (of JBST) remove this @import. Also notice for the parent style.css can’t be excluded by removing wp_enqueue_style( 'jbst-style', get_stylesheet_uri() ); cause some child themes will relay on it’s own style.css instead of only LESS code (custom.less).

Plugin’s stylesheets

My test site use a Question and Asnswer plugin, i found it’s style sheet included on my front page as well. On the front page this style sheet shouldn’t load.

Prevent Plugin’s from loading

By default WordPress loads all plugins (including CSS and JavaScript) on all pages. This also mean performance can be improved at two different stages: prevent the plugin from loading at all and prevent the style sheets and JavaScript from loading.

First a found the “Selective Loading Plugin”. This plugin looks promising, but seems not to work well or at least as expected. After add the class initialization which was missing, the settings interface won’t work too. I found some plugins not loading but overall the result was not good.

After this i investigate where plugins load in WordPress’s code. Plugins load in wp-settings.php, there are no hooks for this action defined. Also the old school (and deprecated!) my-hacks.php can not overwrite the loaded plugins.

The only way to prevent plugin from loading, i found, is edit wp-setting.php itself. Plugins are load by including through iterating an array with plugin paths:

// Load active plugins.
foreach ( wp_get_active_and_valid_plugins() as $plugin )
	include_once( $plugin );
unset( $plugin );

So removing paths from this array will prevent them from loading. For my test site i found the plugin path has q-and-a in its name and the plugin should only load if the request uri contains /knowledge-base/. Based on this data i could change the preceding code into:

// Load active plugins.
$plugins = wp_get_active_and_valid_plugins();
foreach($plugins as $key=>$value)
{
if(strstr($value,'q-and-a') &&  !strstr($_SERVER['REQUEST_URI'],'/knowledge-base/')){unset($plugins[$key]);}
}
foreach ( $plugins as $plugin )
        include_once( $plugin );
unset( $plugin );

The above works well. If you know what to code, you can code it effective. You also have to remember that wp-settings.php will be overwritten when upgrading WordPress.

I also found i can’t remove every plugin this way. For example removing WooCommerce cause problems with the shopping button which should be load on every page and requires WooCommerce (global $woocommerce). Maybe a reason to load all by default.

Prevent CSS and Javascript from loading

On How can I reduce the amount of files loaded/included per plugin? i found: “Current versions of WordPress allow for enqueuing later in the flow so you you can, for example, enqueue on your shortcode init/parse.” I will test this soon, cause it seems very useful for my own plugins too.

For now i start conditional dequeue CSS an Javascript i don’t need. For example for WooCommerce this can been done effective by adding some lines to functions.php:

if(function_exists('is_shop') && !is_shop())wp_dequeue_style( 'woocommerce_frontend_styles');

Overall i found some small code changes will have a huge performance profit.

Images

Pagespeed also mentioned: “Losslessly compressing” for some PNG files used. I found OptiPNG can resolve this easy.

Mag ik Bing wel vergeten?

David en Goliath door MichelangeloDeze week kwam google niet alleen met Google+ communities. Microsoft maakt haar social netwerk so.cl ook voor iedereen beschikbaar. Ik heb even rondgekeken op so.cl. In eerste instantie vond ik het veel op Pintrest lijken. Ook van Pintrest vraag ik mij ook nog steeds af wat ik daar zakelijk nou precies mee kan / moet. Er zijn wel mensen die daar ideeën over hebben. Ergens kan ik mij inderdaad wel voorstellen dat een restaurant bijvoorbeeld een foto van een lekker gerecht kan delen. Zelf lever ik meer diensten, die zou ik dan moeten (laten) uittekenen?

Andere vraagstelling dan: En wat wil Microsoft dan met so.cl? De zoekresultaten van Bing meer ‘author-led’ maken, een tegenhanger van Google Authorship dus.

Hoe belangrijk is dat? Om die vraag de beantwoorden zou je eerst moeten weten hoe groot Bing nu eigenlijk is. Ik heb gezocht naar cijfers over het marktaandeel van zoekmachines over 2012. Eigenlijk is er maar weinig te vinden. Marktaandeel zoekmachines in Nederland geeft de cijfers van 2011. Wel is duidelijk dat Google eigenlijk in heel Europa, inclusief Nederland oppermachtig is: Google nog steeds stevig in zadel in Europa. In de Verenigde Staten is het beeld al jaren anders: Bing wint marktaandeel in de Verenigde Staten.

In Nederland zou je Bing en Yahoo dus misschien maar liever vergeten. Anderzijds is het misschien juist een kans. Door juist ook aandacht te geven aan Bing en Yahoo, lukt het misschien uit dat kleine marktaandeel een hogere conversie te halen. Een site die in Google niet te vinden is heeft misschien wel een hoge ranking in Bing. Yahoo maakt gebruik van de technologie van Bing. Dus qua optimalisatie kan dezelfde aanpak gebruikt worden.

Bij gebrek aan cijfers heb ik naar een aantal van mijn eigen websites gekeken. Via Google analytics heb ik gekeken naar het percentage bezoekers dat binnenkomt via Bing:

linkotheek.nl

Google: 93.1
Bing: 3.4
Yahoo: 0.4

babykeur.nl
Google: 98.1
Bing: 0.6
Yahoo: 0.2

webvrouw.nl
Google: 90.0
Bing: 6.3
Yahoo: 1.3

Opvallend zijn de grote verschillen per website en het relatief grote aandeel Bing/Yahoo voor een website als webvrouw.nl. Een conclusie trekken zonder het marktaandeel Bing/Yahoo te kennen is moeilijk. In het geval van webvrouw zou je kunnen zeggen, de site doet het ‘slecht’ in Google, waardoor het aandeel Bing/Yahoo relatief groter wordt. Of precies andersom webvrouw.nl scoort goed voor Bing/Yahoo dat zou voor de andere websites ook haalbaar moeten zijn.

De genoemde websites zijn alle in het Nederlands en gericht op Nederland (België). Toch kan het zo zijn dat een site relatief veel buitenlandse bezoekers aantrekt via de zoekmachines door een hoge ranking op een Engels zoekwoord. Dit zou dan terug te zien moeten zijn in de kwaliteit van het verkeer. Er zijn wel kleine verschillen in de kwaliteit (pagina’s per bezoek, bezoekduur, bounce-rate) in het geval van webvrouw:

kwaliteit van het verkeer op webvrouw.nl

Het verkeer van Bing/Yahoo heeft een vergelijkbare kwaliteit. Deze bezoekers komen dus waarschijnlijk gewoon uit Nederland of zijn op zijn minst Nederlandstalig.

Andere verschillen tussen de website die mogelijk een rol spelen:

Doelgroep

De bezoekers van webvrouw.nl zullen (hopelijk) meer vrouwen dan mannen zijn. Dat zou echter in zekere mate ook op moeten gaan voor babykeur.nl

Technologie

Zowel babykeur.nl als webvrouw.nl zijn gebouwd met wordpress. Dat lijkt het verschil niet te zijn. Wat wel een duidelijke rol kan spelen. Babykeur maakt gebruik van de All in One SEO Pack plugin, terwijl op webvrouw.nl gebruik gemaakt wordt van de WordPress SEO plugin.
Tevens is op webvrouw.nl de afgelopen maanden via de WordPress SEO plugin veel aandacht besteed in het juist instellen van o.a. de links voor Google Authorship en bijvoorbeeld Twitter cards.

History

Er is een verschil het aantal jaren dat de website bestaat. De linkotheek bestaat sinds 1995, via startpunt.vuurwerk.nl en startpunt.cc sinds 2001 op de domeinnaam linkotheek.nl. Webvrouw.nl bestaat sinds 2003. Babykeur is pas sinds 2008 actief.

Bovenstaande vragen en cijfers zijn voor mij wel aanleiding komende weken nog eens verder naar Bing/Yahoo te kijken. Hoe staat het bijvoorbeeld met het aanbod van tools die vergelijkbaar zijn met de Google Webmaster Tools. Spelen sitemaps nog een rol? En in hoeverre maakt Bing/Yahoo reeds gebruik van bijvoorbeeld de rel=”author” metatags en bijvoorbeeld twitter cards?