Advertisement
swte

Exclude scripts on specific pages

Apr 2nd, 2021
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Plugin Name: Swift Performance Tweaks
  3.  * Exclude Scripts on specific pages
  4.  */
  5.  
  6. add_filter('swift_performance_option_exclude-scripts', function($value){
  7.     $pages = array(
  8.         '', // use empty for homepage
  9.         '/page-1',
  10.         '/another-page',
  11.     );
  12.     if (isset($_SERVER['REQUEST_URI']) && in_array(rtrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'/'), $pages)){
  13.         $value[] = 'jquery.min.js';
  14.     }
  15.     return $value;
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement