Advertisement
Aurangajeb

dequeue css-script on mobile WordPress

Nov 9th, 2020 (edited)
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. /** Dequeue CSS/JS file on mobile **/
  2.  
  3. function dequeue_conditional_mobile_styles_scripts() {
  4.   // First check that wp_is_mobile didn't disappear for some reason
  5.   if ( function_exists( 'wp_is_mobile' ) ) {
  6.     //dequeue scripts and styles if it's for a mobile device.
  7.     if ( wp_is_mobile() ) {
  8.       wp_dequeue_style( 'magnific-popup' );
  9.       wp_dequeue_script( 'jquery-magnific-popup' );
  10.     }
  11.   }
  12. }
  13. add_action( 'wp_enqueue_scripts', 'dequeue_conditional_mobile_styles_scripts', 100 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement