Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vpadhariya/f5d0004f6c70b68623891e09d5cce20d to your computer and use it in GitHub Desktop.
Save vpadhariya/f5d0004f6c70b68623891e09d5cce20d to your computer and use it in GitHub Desktop.
WordPress remove query string from static resource
<?php
/**
* Remove query string from static resource
* @param type $src
* @return type
*/
function _remove_script_version($src)
{
$return = $src;
/**
* Remember for some scripts its required like googleapis or
* other third party CDN resources that you need to ignore
*/
if(!stristr($src, 'googleapis'))
{
$parts = explode('?', $src);
$return = $parts[0];
}
return $return;
}
add_filter('script_loader_src', '_remove_script_version', 15, 1);
add_filter('style_loader_src', '_remove_script_version', 15, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment