innocode-digital/wp-deferred-loading

Defer loading of JavaScript and CSS files.

Installs: 12 684

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 14

Forks: 2

Type:wordpress-muplugin

1.4.1 2020-06-24 12:07 UTC

This package is auto-updated.

Last update: 2024-10-24 21:50:42 UTC


README

Description

WordPress plugin for deferred loading of JavaScript and CSS files.

Install

Clone this repo to wp-content/plugins/:

cd wp-content/plugins/
git clone git@github.com:innocode-digital/wp-deferred-loading.git

Activate Deferred loading from Plugins page or WP-CLI: wp plugin activate wp-deferred-loading.

Also you could install it as a Must Use Plugin.

Usage

To defer JavaScript files, add to functions.php of theme:

add_filter( 'deferred_loading_scripts', function () {
    return [
        // List of enqueued scripts.
    ];
} );

or

add_filter( 'deferred_loading_scripts', function () {
    return '*'; // All enqueued scripts.
} );

To defer CSS files, add to functions.php of theme:

add_filter( 'deferred_loading_styles', function () {
    return [
        // List of enqueued styles.
    ];
} );