Results 1 to 4 of 4

Thread: Remove query strings from static resources

  1. #1
    Thread Starter
    Veteran bleem's Avatar
    Join Date
    Feb 2012
    Posts
    1,571
    Thanks
    103
    Thanked 205 Times in 180 Posts

    Remove query strings from static resources

    I was looking for a way to remove query strings using a function while testing my site performance using gtmetrix.com

    I kept getting a low score due to query strings in static resources and a message such as:
    Remove query strings from static resources.

    So after a bit of research and playing around with the code I managed to get a 100% score and no error using this code:


    Code:
    //remove all query strings from script and css files.
    function _remove_script_version( $src ){
            $parts = explode( '?ver', $src );
            return $parts[0];
    }
        add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
        add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
    Just drop it in at the bottom of your child-theme functions.php file


    I would normally charge £10,000 pounds for this fix but you can have it for nothing.

  2. #2
    Veteran almightyeric's Avatar
    Join Date
    Aug 2011
    Location
    Nothern CA, USA
    Posts
    416
    Thanks
    56
    Thanked 19 Times in 16 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  3. #3
    Thread Starter
    Veteran bleem's Avatar
    Join Date
    Feb 2012
    Posts
    1,571
    Thanks
    103
    Thanked 205 Times in 180 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    Veteran almightyeric's Avatar
    Join Date
    Aug 2011
    Location
    Nothern CA, USA
    Posts
    416
    Thanks
    56
    Thanked 19 Times in 16 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Jomark Jobroller dashboard - a monster eater resources
    By forumenfermagem in forum Report JobRoller Bugs
    Replies: 8
    Last Post: August 13th, 2014, 09:44 AM
  2. Samcy Classipress using too much of the server resources. Help please!
    By cswebtech in forum ClassiPress General Discussion
    Replies: 8
    Last Post: November 26th, 2013, 07:50 PM
  3. High resources used by clasipress..
    By ramystyle in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: October 1st, 2012, 08:02 AM
  4. Can I remove all categories and have a static page in that area?
    By parry_2004 in forum ClassiPress General Discussion
    Replies: 1
    Last Post: December 12th, 2011, 08:14 AM
  5. Remove title tag from static home page
    By lucysofiano in forum JobRoller General Discussion
    Replies: 2
    Last Post: May 20th, 2011, 05:33 AM