How to automatically version WordPress assets using their last modified time
Last updated • October 1st, 2019
Versioning your assets in WordPress is relatively straight-forward as the wp_register_script() and wp_register_style() functions both offer support for specifying a version as a function parameter.
It’s easy to use because you simply pass it a value but it’s also simple to forget which could result in site visitors loading up stale versions of CSS and JS from a cache.
Thankfully, PHP provides us with an easy method of ensuring the version parameter changes whenever the file changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters