Advertisement
swte

Disable scripts on specific pages

Mar 26th, 2021
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. add_filter('swift_performance_option_block-scripts', function($scripts){
  4.     $pages = array(
  5.         '', // use empty for homepage
  6.         '/contact',
  7.         '/reservation',
  8.     );
  9.     if (isset($_SERVER['REQUEST_URI']) && in_array(trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'/'), $pages)){
  10.         $scripts[] = 'any-script.js';
  11.         $scripts[] = 'other-script.js';
  12.     }
  13.     return $scripts;
  14. });
  15.  
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement