Why my browser keeps loading old version of custom JavaScript files in \divi\js? [closed]

I have custom JavaScript files in theme\divi\js. I modify these files and upload them to a GoDaddy web server, but the old version of these files keeps loading.

I clear browser cache, disable cache, clear localStorage… I’ve even called GoDaddy tech support to disable CDN cache, but it is still loading the old files until the next day (I’ve discovered the refreshing pattern… but I’m still not sure about it). I even turned off the WordPress Super Cache.

Why are the JavaScript files not able to load instantly, and how can I control this?

1 Answer
1

First get datetime stamp of your js file’s last modification, and use it as fourth parameter of wp_enqueue_script function:

$path="full path to your script file");
$handle="your_handle"; 
$src="https://wordpress.stackexchange.com/questions/283374/path of the script, relative to the WordPress root directory";
$depts = array(); // dependencies, if any
$ver = filemtime($path);
$in_footer = false;

wp_enqueue_script($handle, $scr, $depts, $ver, $in_footer);

If the datetime stamp changes, your updated script will be loaded, otherwise the cached script will be loaded.

Leave a Comment