PHP code example of markjaquith / encute

1. Go to this page and download the library: Download markjaquith/encute 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/ */

    

markjaquith / encute example snippets




use CWS\Encute\Plugin;
use CWS\Encute\Script;
use CWS\Encute\Style;

add_action(Plugin::class, function (Plugin $encute) {
	$encute->debug(); // Optional: Adds HTML comments to scripts and styles, making it easier to see the handle.

	// Move jQuery to footer and defer its loading.
	Script::get('jquery')->footer()->defer();

	// Move 'some-handle' to the footer.
	Script::get('some-handle')->footer();

	// Defer 'wp-embed'.
	Script::get('wp-embed')->defer();
	
	// Make 'some-module' load as a module.
	Script::get('some-module')->module();
	
	// Make 'nomodule-fallback' load as nomodule.
	Script::get('nomodule-fallback')->noModule();
	
	// Move 'admin-bar' styles to the footer and defer their loading.
	Style::get('admin-bar')->footer()->defer();

	// Move 'wp-block-library' styles to the footer.
	Style::get('wp-block-library')->footer();

	// Keep 'contact-form-7' style on contact page only.
	Style::get('contact-form-7')->keepIf(fn() => is_page('contact'));

	// Remove 'cruft' script on the about page.
	Script::get('cruft')->removeIf(fn() => is_page('about'));
});

add_action(\CWS\Encute\Plugin::class, function (\CWS\Encute\Plugin $encute) {
	// Your code here.
});