WordPress Snippet: Remove Query string of static file


Notice: A non well formed numeric value encountered in /home/wiseguys/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/wiseguys/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Notice: A non well formed numeric value encountered in /home/wiseguys/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/wiseguys/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Today I got a chance to remember all the ways I made a website base on WordPress, suddenly everything just went to only last point is optimize it to load faster.

I usually use GTMetrix to analyzed my page and other sites I did, the annoying things appear is the tip “Remove query strings from static resources”, which GTMetrix explained:

Resources with a “?” in the URL are not cached by some proxy caching servers.

I tried to use the plugins like W3C Total Cache or WP Super Cache but none of them work, so I made my way with the following snippet:

The snippet above will help you remove the ? query string, you can paste it to your functions.php file. Voila!

If the snippet above does not work, you can try this one too

The 2 snippet just work for me, it should work for you too. Have fun!

Leave A Comment

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