Hi tagDiv,
I tried to remove query string from all resources.
Mention: whit the plugin Speed-Boostser activated or not allways bring the same results, so discarded.
So, using functions like:
function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
or
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
… for all other resource works but only this resources are untouched:
- http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,600,700&ver=7.4
- http://fonts.googleapis.com/css?family=Roboto:500,400italic,700,900,500italic,400,300&ver=7.4
- http://domain.com/wp-content/plugins/js_composer/assets/css/js_composer.min.css?ver=7.4
- http:///domain.com/wp-content/themes/BT/style.css?ver=7.4
Why is not possible?
I know that this practice ensure you that the browser will not be able to store them in cache and users allways will see the right version from each update.
Thanks.
Hello nairolf,
It could be useful for you if you try to increase the priority to a higher value. Also, if you are using the Speed Booster, please ensure that you use a higher value greater than 1002 as the priority. Please notice that all of this customization involves custom work and we cannot provide this type of services at the moment, sorry!
If you want to deeper develop our theme and if you are not aware of the steps which are needed to take in this regard, please consider hiring a freelancer/developer to help you!
Thanks for your understanding!
Hi Catalin,
You are kind to provide a simple example how you encrease that priority?
I will not insist, if you want to help me (ok and thank you very much), if not, do not answer me.
I don’t need deeper develop, and I don’t hiring a freelancer only for this.
Thank you.
Hi
You can try something like this:
add_filter( 'style_loader_src', 'remove_cssjs_ver', 1005, 2 );
1005 is the priority value, you need a small priority for this hook if speed booster is used. In this case a higher number means a smaller priority.
Hope this helps!
Thanks!
Hi Andrei L. / Catalin,
Thank you both for reply
Of course I tried with high priority before to ask here, that’s why I asked for an example.
Previously in another topic some days ago, talking with @neotrope (Chris S), he has advised me to increase the priority. I tried on my end all possibilities and combinations: increasing/decreasing the priority, enable/disable speed-booster but allways with the same results (the 4 resource thats on top of this topic remain untouched).
Hi
I’ve made an additional tests and seems that the scripts moved by speed booster in footer can’t be accessed by that function. Instead you can try to remove the query string directly from Speed Booster, just replace the original code with this one: http://screencast.com/t/bMhSDZwi
foreach ($this->style_footer_queue as $style_id => $wp_dependency_object) {
if (strrpos($wp_dependency_object->src, '?') === false) {
echo "<link rel='stylesheet' id='" . $style_id . "-css' href='" . $wp_dependency_object->src . "' type='text/css' media='" . $wp_dependency_object->args . "' />\n";
} else {
echo "<link rel='stylesheet' id='" . $style_id . "-css' href='" . $wp_dependency_object->src . "' type='text/css' media='" . $wp_dependency_object->args . "' />\n";
}
}
Hope this help!
Thanks!
Hi Chris S, indeed it would be great!
A little advice for that users who will want to use this improvement for Speed-booster plugin.
Using this code in combination for example with that one provided by Chris S in his [tutorial], you’ll have a double-edged knife (you’re warned! ๐ ) if not used with caution.
Good to know: even if you update your theme to a new version, browsers/CDNs/… and in the end users, they all not recognize your changes until your rules for “Expire headers” will expire! and I’m sure that you’ll go crazy the tagDiv staff ๐ with: “my users not seen me changes/updates” or similar.
In addition it should be recalled that a normal users (visitors) which makes search on Internet, will not erase the cache from their devices to see our web (recent version).
So, if you are use this snippet, use it with precaution in combination with an flexible time for expire headers depending on your activity!
Can be controled also by Cache-Control Headers but that’s another story apart
———-
Summary to remove query strings from static resources with Speed-Booster enabled:
• For functions.php (a slim version ๐ )
function remove_js_ver( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'script_loader_src', 'remove_js_ver', 10, 2 );
• For td-speed-booster.php
foreach ($this->style_footer_queue as $style_id => $wp_dependency_object) {
if (strrpos($wp_dependency_object->src, '?') === false) {
echo "<link rel='stylesheet' id='" . $style_id . "-css' href='" . $wp_dependency_object->src . "' type='text/css' media='" . $wp_dependency_object->args . "' />\n";
} else {
echo "<link rel='stylesheet' id='" . $style_id . "-css' href='" . $wp_dependency_object->src . "' type='text/css' media='" . $wp_dependency_object->args . "' />\n";
}
}
Good luck and nice/big traffic to all.
All thanks must go to Andrei L. because he provide us this custom work.
-
This reply was modified 9 years by
nairolf.
Thank you Andreo, Chrish and Nairolf ๐
It worked wonderfully . The version query strings went out but it still appears in the Google Pagespeed Score. We all tried to solve this issue here: https://forum.tagdiv.com/topic/tagdiv-speed-booster-not-removing-js-render-blocking-and-other-related-issue/page/2/ but it didn’t work.
Have you come up with any solution to that?
Hi
There are no query strings in google page-speed test: http://screencast.com/t/H1ElYn5LOuH However one thing must be clearly understood: the theme and speed booster controls only the site, not results generated by different tools used for different tests. Each tool have its own algorithm and may interpret things different but the theme can’t control that.
Thanks!