I’m getting nags on google speed test regarding the querystrings in my scripts. So, I’m trying to remove them by passing false as the argument for that parameter. However, it does not seem to have effect:

wp_register_script('myscript', get_bloginfo('template_directory').'/scripts.myversionnumber.js',false,false,true);
wp_enqueue_script('myscript');

PS: the “myversionnumber” part of the js filename is my means of controlling cache/versioning rather than the ?ver= approach which apparently trips up some proxy servers (according to Google pagespeed test):

Remove query strings from static resources Enabling public caching in
the HTTP headers for static resources allows the browser to download
resources from a nearby proxy server rather than from a remote origin
server. Learn more

Suggestions for this page

Resources with a “?” in the URL are not cached by some proxy caching
servers. Remove the query string and encode the parameters into the
URL for the following resources:

3 s
3

I think you have to pass NULL as the 4th parameter.

wp_register_script(
    'myscript',
    get_bloginfo('template_directory').'/scripts.myversionnumber.js',
    false,
    NULL,
    true);
wp_enqueue_script('myscript');

Leave a Reply

Your email address will not be published. Required fields are marked *