Skip to content

Instantly share code, notes, and snippets.

@kjbrum
Last active January 15, 2022 19:31
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save kjbrum/76a301b9086357a89bab to your computer and use it in GitHub Desktop.
Save kjbrum/76a301b9086357a89bab to your computer and use it in GitHub Desktop.
Automated Cache Busting. This works by adding the file's change time to the end of the URL (last argument of the call)
<?php
/* For Themes */
wp_enqueue_style('slug', get_template_directory_uri().'/css/slug.css', array(), filemtime(get_template_directory().'/css/slug.css'));
wp_enqueue_script('slug', get_template_directory_uri().'/js/slug.js', array(), filemtime(get_template_directory().'/js/slug.js'));
/* For Plugins */
wp_enqueue_style('slug', plugin_dir_url(__FILE__).'css/slug.css', array(), filemtime(plugin_dir_path(__FILE__).'css/slug.css'));
wp_enqueue_script('slug', plugin_dir_url(__FILE__).'js/slug.js', array(), filemtime(plugin_dir_path(__FILE__).'js/slug.js'));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment