Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

ThemePlate/Preload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThemePlate Preload (Legacy)

Check out the Resource package.

Usage

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 )

Preload resources manually specifying their attributes in an array format

  • $list (array)(Required) List of wanted resources to preload

apply_filters( 'themeplate_preload_dependencies', $list )

Preload registered dependencies using their unique handles

  • $list (array)(Required) List of registered dependencies to preload