How to remove query string from static resource in WordPress?

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question









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
















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.










share|improve this question









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












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.










share|improve this question









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






share|improve this question









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.











share|improve this question









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.









share|improve this question




share|improve this question








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












  • 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










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





share|improve this answer
















  • 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











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "110"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Rakesh Patidar is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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






























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





share|improve this answer
















  • 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















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





share|improve this answer
















  • 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













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





share|improve this answer












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






share|improve this answer












share|improve this answer



share|improve this answer










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













  • 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











Rakesh Patidar is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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.













 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

Confectionery