themeplate / preload
v1.0.2
2021-10-23 14:14 UTC
Requires
- php: ^7.2|^8.0
This package is auto-updated.
Last update: 2022-06-05 08:50:03 UTC
README
查看 Resource 包。
使用方法
add_action( 'wp_head', array( 'ThemePlate\Preload', 'init' ), 2 ); add_filter( 'themeplate_preload_resources', function( $list ) { $list[] = array( 'href' => 'https://fonts.gstatic.com/s/montserrat/v14/JTURjIg1_i6t8kCHKm45_cJD3gTD_u50.woff2', 'as' => 'font', 'type' => 'font/woff2', ); return $list; } ); add_filter( 'themeplate_preload_dependencies', function( $list ) { $list[] = 'jquery-core'; $list[] = 'theme-script'; return $list; } );
apply_filters( 'themeplate_preload_resources', $list )
手动指定数组格式中的属性以预加载资源
- $list (数组)(必需) 要预加载的资源列表
apply_filters( 'themeplate_preload_dependencies', $list )
使用唯一的句柄预加载已注册的依赖项
- $list (数组)(必需) 要预加载的已注册依赖项列表