The changes I make to an external JS file of my WP plugin are only applied after I clear my browser’s cache

Use function filemtime($path), where $path is a path to your script, in wp_enqueue_script call, as fourth parameter (version). Every time you modify the script, the cache will be bypassed.

Update

Calls to wp_register_script and wp_enqueue_script:

wp_register_script('DynamicMapScript', plugins_url('DynamicMap.js', __FILE__), array('jquery'), filemtime(dirname(__FILE__) . '/DynamicMap.js'));
wp_enqueue_script('DynamicMapScript');

Leave a Comment