PHP code example of themeplate / preload

1. Go to this page and download the library: Download themeplate/preload library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

themeplate / preload example snippets


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;
} );