innocode-digital / wp-deferred-loading
延迟加载 JavaScript 和 CSS 文件。
1.4.1
2020-06-24 12:07 UTC
Requires
- composer/installers: ~1.0
This package is auto-updated.
Last update: 2024-09-24 21:39:42 UTC
README
描述
WordPress 插件,用于延迟加载 JavaScript 和 CSS 文件。
安装
将此仓库克隆到 wp-content/plugins/
cd wp-content/plugins/
git clone git@github.com:innocode-digital/wp-deferred-loading.git
从插件页面激活 延迟加载 或使用 WP-CLI:wp plugin activate wp-deferred-loading
。
您也可以将其作为 必用插件 安装。
使用方法
要延迟加载 JavaScript 文件,请将其添加到主题的 functions.php
文件中
add_filter( 'deferred_loading_scripts', function () {
return [
// List of enqueued scripts.
];
} );
或
add_filter( 'deferred_loading_scripts', function () {
return '*'; // All enqueued scripts.
} );
要延迟加载 CSS 文件,请将其添加到主题的 functions.php
文件中
add_filter( 'deferred_loading_styles', function () {
return [
// List of enqueued styles.
];
} );