Skip to content

Instantly share code, notes, and snippets.

@carl-alberto
Created October 13, 2020 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carl-alberto/d2e3ba70101e4ea76cb4d20e5d96d382 to your computer and use it in GitHub Desktop.
Save carl-alberto/d2e3ba70101e4ea76cb4d20e5d96d382 to your computer and use it in GitHub Desktop.
sample WordPress dequeue with certain user-agent is detected
function bot_detected() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
if(strlen(strstr($u_agent,"Lighthouse")) > 0 ){
return false;
} else {
return true;
}
}
add_action( 'init', 'my_deregister_init', 9999999999999999 );
function my_deregister_init() {
if ( is_front_page() ) {
wp_dequeue_script( 'bootstrap' );
wp_deregister_script( 'bootstrap' );
}
}
add_action( 'wp_enqueue_scripts', 'my_deregister_javascript', 9999999999999999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment