WordPress.org

Ready to get started?Download WordPress

Forums

how to Remove query strings from static resources (20 posts)

  1. kletskater
    Member
    Posted 2 years ago #

    I was messuring load time with pingdom.com/tools.
    they reccoment Remove query strings from static resources.
    How do I do that?

  2. vtxyzzy
    Member
    Posted 2 years ago #

    What they are recommending is that you look for queries where the result never changes. Replace those queries with the HTML that was generated from the queries.

  3. kletskater
    Member
    Posted 2 years ago #

    thanks for replying but this souds like chinese to me:-)
    Wouldn't know where to look for

  4. bluejpro
    Member
    Posted 2 years ago #

    This recommendation may point to a file created by w3 total cache. In my case, pingdom is referring to a file which (I'm guessing) is on the disc cache, which w3c finds using a query for example:

    .../w3tc/min/index.php?file=635bc/default.include.nnnnn.cxx

    Any way round this?

  5. kletskater
    Member
    Posted 2 years ago #

    yes that may be due to W3TC: i've got a bunch of them.
    here are some of them
    /wp-content/plugins/clickdesk-live-support-chat-plugin/js/widget.js?9d8528
    /wp-content/plugins/contact-form-7/jquery.form.js?9d8528
    /wp-content/plugins/contact-form-7/scripts.js?9d8528
    /wp-content/plugins/contact-form-7/styles.css?9d8528
    /wp-content/plugins/count-per-day/counter.css?9d8528
    /wp-content/plugins/dmsguestbook/dmsguestbook.css?9d8528
    /wp-content/plugins/google-analytics-for-wordpress/custom_se_async.js?9d8528
    /wp-content/plugins/jetpack/modules/wpgroho.js?9d8528
    /wp-content/plugins/share-and-follow/images/blank.gif?9d8528
    /wp-content/plugins/wp-photo-album-plus/images/tick.png?9d8528
    /wp-content/plugins/wp-photo-album-plus/theme/wppa-style.css?9d8528
    /wp-content/plugins/wp-photo-album-plus/wppa-slideshow.js?9d8528
    /wp-content/plugins/wp-photo-album-plus/wppa-theme.js?9d8528
    /wp-content/themes/atahualpa373/js/jquery.cross-slide.js?9d8528
    /wp-content/uploads/2010/06/we-hebben-kittens11.gif?9d8528
    /wp-includes/js/comment-reply.js?9d8528
    /wp-includes/js/l10n.js?9d8528
    /wp-includes/js/thickbox/thickbox.css?1
    /wp-includes/js/thickbox/thickbox.js?9d8528
    pingdom says: Remove the query string and encode the parameters into the URL for the following resources.
    How do I do that?

  6. Justin Givens
    Member
    Posted 2 years ago #

    I just ran across this post sharepointjohn.com and it has two filters you can add to remove stylesheets and javascript.

  7. RobertKn
    Member
    Posted 2 years ago #

    If you Use "W3 Total Cache" - W3TC you may switch off "Prevent caching of objects after settings change" in Browser Cache.

    This removes query strings from static resources.

    best Regards

    Robert

  8. kletskater
    Member
    Posted 2 years ago #

    hi Justin tried the code at sharepointjohn.com but it brakes my site so that wont work for me.

    Robertkn
    Thanks for your suggestion will try that one

  9. sariyantamade
    Member
    Posted 2 years ago #

    Justin Givens has given me the solution i was looking for. Thank you, now my site performance in PageSpeed is 90 :D

  10. LeonelLeonel
    Member
    Posted 2 years ago #

    I add the following code to remove the query strings from CSS & JS and it worked on all but the following http://yourgreendrycleaner.com/wp-content/plugins/audio-player/assets/audio-player.js?ver=2.0.4.1 ... any suggestions?

    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 );

  11. kletskater
    Member
    Posted 2 years ago #

    @Leonel
    placed your code in my .htaccess, breaks my site

  12. adpawl
    Member
    Posted 2 years ago #

    @LeonelLeonel, edit plugin file ...audio-player.php
    change 715 line
    echo '<script type="text/javascript" src="' . $this->pluginURL . '/assets/audio-player.js?ver=' . $this->version . '"></script>';
    to
    echo '<script type="text/javascript" src="' . $this->pluginURL . '/assets/audio-player.js"></script>';

    @kletskater, this code is not for .htaccess, but for functions.php

  13. LeonelLeonel
    Member
    Posted 2 years ago #

    @kletskater, I concur with adpawl, you should place the code in your theme’s function file (Appearance > Editor > Functions.php)and add it before the closing PHP tag

    @adpawl, thanks! that worked ...

  14. Pardeep
    Member
    Posted 2 years ago #

    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:

    http://www.parupedia.com/wp-content/plugins/wp-minify/min/?f=wp-content/themes/thesis_184/custom/layout.css,wp-content/themes/thesis_184/custom/custom.css&m=1341427628

    getting this problem please help me

  15. LinuXplained
    Member
    Posted 1 year ago #

    RobertKn is right. W3 Total Cache could cause this problem. Take a look at this post:

    http://j.mp/Mf1RIe

  16. Versha
    Member
    Posted 1 year ago #

    The code worked wonders on my site, however it didn't remove the query string from the theme's .css and .js files as these are not version strings. any thoughts on how i can get rid of these?

  17. bilgedede.org
    Member
    Posted 1 year ago #

    Very Easy Method:
    In your theme’s function file (Appearance > Editor > Functions.php), add the following code before the closing PHP tag (%>) at the bottom of the file:

    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 );

    Visual : http://www.bilgedede.org
    Source: http://www.tricksmachine.com/2012/04/remove-query-strings-from-static-resources.html#comment-747724

  18. danielmichel
    Member
    Posted 1 year ago #

    I don't suppose the above can be done using a plugin that minifys such as better wp minify?

  19. m1mi.dan0s
    Member
    Posted 1 year ago #

    For those who get this results and are using W3TC, here's the solution: http://wordpress.org/support/topic/plugin-w3-total-cache-remove-query-string-from-static-content?replies=5

    No crazy extra scripts, just unchecking a box in browser cache settings.

  20. danielmichel
    Member
    Posted 1 year ago #

    [edit]replying to wrong thread

Topic Closed

This topic has been closed to new replies.

About this Topic