PHP code example of wpscholar / wp-async-defer-scripts

1. Go to this page and download the library: Download wpscholar/wp-async-defer-scripts 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/ */

    

wpscholar / wp-async-defer-scripts example snippets







add_action( 'wp_enqueue_scripts', function () {
	wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js' );
	wp_scripts()->add_data( 'recaptcha', 'async', true );
} );



add_action( 'wp_enqueue_scripts', function () {
	wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js' );
	wp_scripts()->add_data( 'recaptcha', 'defer', true );
} );



wpscholar\WordPress\AsyncDeferScripts::initialize();