Skip to content

Instantly share code, notes, and snippets.

@morvy
Created March 30, 2020 16:46
Show Gist options
  • Save morvy/e533d67b3e4db908d59bada019e5455d to your computer and use it in GitHub Desktop.
Save morvy/e533d67b3e4db908d59bada019e5455d to your computer and use it in GitHub Desktop.
[WPR exclude defer] Exclude scripts from WP Rocket’s defer JS option. #wordpress #wprocket
/**
* Exclude scripts from WP Rocket’s defer JS option.
*
* @author Caspar Hübinger
* @param array $excluded_files Array of script URLs to be excluded
* @return array Extended array script URLs to be excluded
*/
function exclude_files( $excluded_files = array() ) {
/**
* EDIT THIS:
* Edit below line as needed to exclude files.
* To exclude mupltiple files, copy the entire line into a new line for each file you wish you exclude.
*/
$excluded_files[] = '/wp-content/themes/child-theme/assets/js/jquery2.min.js';
// STOP EDITING
return $excluded_files;
}
add_filter( 'rocket_exclude_defer_js', 'WP_Rocket\Helpers\static_files\exclude\defer_js\exclude_files' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment