2017 © Pedro Peláez
 

library wp-page-speed-optimization

A library for WordPress.

image

inc2734/wp-page-speed-optimization

A library for WordPress.

  • Friday, July 27, 2018
  • by inc2734
  • Repository
  • 1 Watchers
  • 0 Stars
  • 392 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 150 % Grown

The README.md

WP Page Speed Optimization

CI Latest Stable Version License, (*1)

Install

$ composer require inc2734/wp-page-speed-optimization

How to use

Initialize (Require)

<?php
// When Using composer auto loader
new Inc2734\WP_Page_Speed_Optimization\Bootstrap();

Add defer attribute

add_filter( 'inc2734_wp_page_speed_optimization_defer_scripts', function( $handles ) {
    return array_merge( $handles, [
        get_template(),
        get_stylesheet(),
    ] );
} );

Add async attribute

add_filter( 'inc2734_wp_page_speed_optimization_async_scripts', function( $handles ) {
    return array_merge( $handles, [
        'comment-reply',
        'wp-embed',
    ] );
} );

Optimize jQuery loading

Load jQuery and other scripts as defer + head as much as possible., (*2)

add_filter( 'inc2734_wp_page_speed_optimization_optimize_jquery_loading', '__return_true' );

Use HTTP/2 Server Push

add_filter( 'inc2734_wp_page_speed_optimization_do_http2_server_push', '__return_true' );
add_filter( 'inc2734_wp_page_speed_optimization_http2_server_push_handles', function( $handles ) {
    return $handles;
} );
add_filter( 'inc2734_wp_page_speed_optimization_link_prefetching', '__return_true' );
add_filter( 'inc2734_wp_page_speed_optimization_link_prefetching_selector', '.l-header, .l-contents__main' );
add_filter( 'inc2734_wp_page_speed_optimization_link_prefetching_interval', 2000 );
add_filter( 'inc2734_wp_page_speed_optimization_link_prefetching_connections', 1 );

Output CSS to head

add_filter( 'inc2734_wp_page_speed_optimization_output_head_styles', function( $handles ) {
    return array_merge( $handles, [
        get_template(),
        get_stylesheet(),
    ] );
} );

Preload Styles

add_filter( 'inc2734_wp_page_speed_optimization_preload_stylesheets', function( $handles ) {
    $wp_styles = wp_styles();
    $preload_handles = $wp_styles->queue;

    if ( in_array( get_template(), $preload_handles ) ) {
        unset( $preload_handles[ get_template() ] );
    }

    if ( in_array( get_stylesheet(), $preload_handles ) ) {
        unset( $preload_handles[ get_stylesheet() ] );
    }

    return array_merge( $handles, $preload_handles );
} );

Use browser cache with .htaccess

// If `set-expires-header` customize setting
add_action( 'customize_save_set-expires-header', function( $customize_setting ) {
    if ( $customize_setting->post_value() === $customize_setting->value() ) {
        return;
    }

    \Inc2734\WP_Page_Speed_Optimization\Helper\write_cache_control_setting( (bool) $customize_setting->post_value() );
} );

Cache nav menus

// If using nav menu caching, remove all current classes.
add_filter( 'inc2734_wp_page_speed_optimization_caching_nav_menus', '__return_true' );

Cache sidebars

// in functions.php
add_filter( 'inc2734_wp_page_speed_optimization_caching_sidebars', '__return_true' );

// in template
\Inc2734\WP_Page_Speed_Optimization\Page_Speed_Optimization\Helper\dynamic_sidebar( 'footer-widget-area' );

Async loading of attachment image

add_filter( 'inc2734_wp_page_speed_async_attachment_images', '__return_true' );

Async loading of content image

add_filter( 'inc2734_wp_page_speed_async_content_images', '__return_true' );

The Versions

25/07 2018

0.7.0

0.7.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

06/06 2018

0.6.1

0.6.1.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

23/05 2018

0.6.0

0.6.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

09/05 2018

0.5.1

0.5.1.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

08/05 2018

0.5.0

0.5.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

02/05 2018

0.4.0

0.4.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

01/05 2018

0.3.0

0.3.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

01/05 2018

0.2.0

0.2.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

28/04 2018

0.1.1

0.1.1.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

28/04 2018

0.1.0

0.1.0.0

A library for WordPress.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires