'remove_query_strings', 'title' => 'Remove query strings from CSS/JS', 'desc' => 'Remove ?ver= from CSS and JS URLs', 'icon' => 'code', 'help' => 'WordPress adds ?ver= to CSS and JS URLs. The value changes when a file is updated, which tells browsers and caches to fetch the new file. This feature removes it from every stylesheet and script URL. Some older proxy caches did not cache URLs with query strings; most current CDNs and browsers cache them normally. Without the version, visitors may keep an old cached copy of a file for a while after you update a plugin, theme or WordPress.', 'before' => 'style.css?ver=1.2.3', 'after' => 'style.css', 'benefit' => 'Only helps if a cache in front of your site skips URLs with query strings. Check that first: on most hosts and CDNs this changes nothing, and it removes the automatic cache refresh after updates.', 'level' => 'beginner', 'audience' => 'everyone', 'priority' => 3, 'detect' => function () { return array( 'detected' => true, 'message' => 'Query strings on static assets hurt caching', 'safe' => true, 'savings' => 'Better CDN/proxy caching', ); }, 'callback' => function () { $strip = function ( $src ) { if ( strpos( $src, 'ver=' ) !== false ) { $src = remove_query_arg( 'ver', $src ); } return $src; }; add_filter( 'style_loader_src', $strip, 9999 ); add_filter( 'script_loader_src', $strip, 9999 ); }, );