Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Skip When No Version Query String
Lab: Remove Query String from Static Resource URL
Video Runtime: 09:18
What if no version query string was applied to the asset’s URL? Then there’s no reason for us to run the conversion code. Right? That regex pattern is slow. So we don’t want to run it unless it’s needed.
When does WordPress not append a version query string? Think about it. Go look up wp_enqueue_script
. Look at the description for the version parameter.
Pro Tip: Set External URLs to Null
When enqueue external stylesheets or scripts, set the version number to null
. WordPress will then not apply the ?ver=
query string to that asset’s URL. Let the external website handle their own assets.
In this episode, we’ll explore 2 different techniques of checking if the incoming asset’s URL has the version query string.
Hands off the keyboard. Web development starts by thinking first, then planning it out, and then coding it.
Episodes
Total Lab Runtime: 03:18:22
- 1 Lab Introductionfree 09:30
- 2 What is a URL Query String?free 14:36
- 3 The Intent of ?ver=1.0.0free 12:22
- 4 Understanding the Problemfree 14:01
- 5 Cache Busting Strategiesfree 09:57
- 6 Planning Our Pluginpro 18:17
- 7 Versioning Utility Helper Filepro 08:36
- 8 Start the URL Converter Classpro 18:11
- 9 Hook into WordPresspro 11:57
- 10 Regex or Parse the URL?pro 12:30
- 11 Convert with Regexpro 06:10
- 12 Apache and Nginx Rewrite Rulespro 10:43
- 13 Deciding Whether to Convertpro 07:35
- 14 Skip When No Version Query Stringpro 09:18
- 15 Only the Local Assetspro 14:09
- 16 Improving Our Code & Readabilitypro 11:52
- 17 Test, Fine-Tune, and Wrap it Uppro 08:38