How to remove query string from static resource in WordPress?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I have this type of query string, Like:
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js?ba0a5a&ba0a5a
https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js?ba0a5a&ba0a5a
https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css?ba0a5a&ba0a5a
How to remove, for example, ?ba0a5a&ba0a5a, from the URL.
customization query-string
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
I have this type of query string, Like:
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js?ba0a5a&ba0a5a
https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js?ba0a5a&ba0a5a
https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css?ba0a5a&ba0a5a
How to remove, for example, ?ba0a5a&ba0a5a, from the URL.
customization query-string
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
These don't look "normal" and WP doesn't natively load jQuery from a CDN. I would recommend to determine where are they coming from and why do they get queries attached first.
– Rarst
yesterday
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have this type of query string, Like:
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js?ba0a5a&ba0a5a
https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js?ba0a5a&ba0a5a
https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css?ba0a5a&ba0a5a
How to remove, for example, ?ba0a5a&ba0a5a, from the URL.
customization query-string
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have this type of query string, Like:
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js?ba0a5a&ba0a5a
https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js?ba0a5a&ba0a5a
https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css?ba0a5a&ba0a5a
How to remove, for example, ?ba0a5a&ba0a5a, from the URL.
customization query-string
customization query-string
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday


Castiblanco
1,78721020
1,78721020
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked yesterday
Rakesh Patidar
111
111
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Rakesh Patidar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
These don't look "normal" and WP doesn't natively load jQuery from a CDN. I would recommend to determine where are they coming from and why do they get queries attached first.
– Rarst
yesterday
add a comment |Â
2
These don't look "normal" and WP doesn't natively load jQuery from a CDN. I would recommend to determine where are they coming from and why do they get queries attached first.
– Rarst
yesterday
2
2
These don't look "normal" and WP doesn't natively load jQuery from a CDN. I would recommend to determine where are they coming from and why do they get queries attached first.
– Rarst
yesterday
These don't look "normal" and WP doesn't natively load jQuery from a CDN. I would recommend to determine where are they coming from and why do they get queries attached first.
– Rarst
yesterday
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
You can remove the Query Strings using this code in your functions.php
function _remove_query_strings( $src )
$parts = explode( '?', $src );
return $parts[0];
add_filter( 'script_loader_src', '_remove_query_strings', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings', 15, 1 ); //not need to in your case since it's for the CSS files
2
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
You can remove the Query Strings using this code in your functions.php
function _remove_query_strings( $src )
$parts = explode( '?', $src );
return $parts[0];
add_filter( 'script_loader_src', '_remove_query_strings', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings', 15, 1 ); //not need to in your case since it's for the CSS files
2
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
add a comment |Â
up vote
2
down vote
You can remove the Query Strings using this code in your functions.php
function _remove_query_strings( $src )
$parts = explode( '?', $src );
return $parts[0];
add_filter( 'script_loader_src', '_remove_query_strings', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings', 15, 1 ); //not need to in your case since it's for the CSS files
2
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can remove the Query Strings using this code in your functions.php
function _remove_query_strings( $src )
$parts = explode( '?', $src );
return $parts[0];
add_filter( 'script_loader_src', '_remove_query_strings', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings', 15, 1 ); //not need to in your case since it's for the CSS files
You can remove the Query Strings using this code in your functions.php
function _remove_query_strings( $src )
$parts = explode( '?', $src );
return $parts[0];
add_filter( 'script_loader_src', '_remove_query_strings', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings', 15, 1 ); //not need to in your case since it's for the CSS files
answered yesterday


Castiblanco
1,78721020
1,78721020
2
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
add a comment |Â
2
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
2
2
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
While this answers question literally, I highly recommend to never do this unconditionally for all scripts/styles. It's very normal for WP core and extensions to use query strings for versioning of assets (which is suboptimal technique from cache perspective, but it is what it is).
– Rarst
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Use it "at your own risk" I should've added. Thanks.
– Castiblanco
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
Yeah, wouldn't this break cache-revving via url params? I think OP should find where those scripts are enqued and remove the query-strings manually. do a global search in the theme for enqueue_script &/or the urls that have query-strings added to them & see if there's a simpler (more concise less global) solution (like just removing the query strings or adding an exception to the filter which is adding them in the first place).
– admcfajn
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
This function removes only ?v,?var type query string but not remove ?ba0a5a&ba0a5a this type query string. This function not working.
– Rakesh Patidar
yesterday
add a comment |Â
Rakesh Patidar is a new contributor. Be nice, and check out our Code of Conduct.
Rakesh Patidar is a new contributor. Be nice, and check out our Code of Conduct.
Rakesh Patidar is a new contributor. Be nice, and check out our Code of Conduct.
Rakesh Patidar is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f313889%2fhow-to-remove-query-string-from-static-resource-in-wordpress%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
These don't look "normal" and WP doesn't natively load jQuery from a CDN. I would recommend to determine where are they coming from and why do they get queries attached first.
– Rarst
yesterday