WordPress makes enqueuing assets super simple and generally does its very best to keep those assets up to date where possible but we can take this a step further and use PHP’s
An example of automatic versioning when using
By simply passing the asset’s full file path to
filemtime() and using that in the
$version parameter of either
wp_register_script(), we can let PHP & WordPress manage the file’s version number and update the URI as we make changes to the files.
wp_enqueue_script() can also register assets for us directly
It is possible to skip the use of the
wp_register_script() functions in the previous example and instead pass the additional arguments directly to the enqueue functions. Under the hood, the enqueue functions check for additional arguments and found, will register the asset before enqueuing.