Can remove unnecessary "ver" parameter from JS file
-
@webvitaly Two minor things with v3.1 (neither of which really impacts its operations):
1) It doesn’t look like you upped the version number in the filename. You still have 3.0 instead of 3.1 within the .zip:
/anti-spam/js/anti-spam-3.0.js
Since the contents of the .js file hasn’t changed, it doesn’t make any real-world impact, but just thought I’d bring it to your attention in case it was an oversight.
2) Since you’re now revving the version number within the anti-spam.js filename, you no longer need to specify a version number within ‘wp_enqueue_script’. Right now, WordPress is rendering the following HTML output:
https://www.example.com/wp-content/plugins/anti-spam/js/anti-spam-3.0.js?ver=3.1
The ?ver=3.1 query string cache bust is unnecessary, as you’re already cache-busting by updating the anti-spam file name when you initiate your upgrades.
Altering line 34, from this:
wp_enqueue_script('anti-spam-script', plugins_url('/js/anti-spam-3.0.js', __FILE__), array('jquery'), $antispam_settings['version'], true);
to this:
wp_enqueue_script('anti-spam-script', plugins_url('/js/anti-spam-3.0.js', __FILE__), array('jquery'), null, true);
results in a clean URL without the superfluous query string cruft, such as:
https://www.example.com/wp-content/plugins/anti-spam/js/anti-spam-3.0.js
- The topic ‘Can remove unnecessary "ver" parameter from JS file’ is closed to new replies.