Created
October 13, 2020 02:38
-
-
Save carl-alberto/d2e3ba70101e4ea76cb4d20e5d96d382 to your computer and use it in GitHub Desktop.
sample WordPress dequeue with certain user-agent is detected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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