Find yourself constantly battling browser cache when developing a script in WordPress?
This snippet will always give you a fresh copy of all the scripts and styles loaded via wp_enqueue_script() and wp_enqueue_style():
function pmc_dev_cachebuster( $src ) { return add_query_arg( 'ver', time(), $src ); } add_filter( 'style_loader_src', 'pmc_dev_cachebuster' ); add_filter( 'script_loader_src', 'pmc_dev_cachebuster' );
Don’t ever commit that to production though… 😉
LikeLike
Haha yes… filed under “goes without saying”. Oh I know, I’ll tag it!
LikeLike