WordPress not updating the js file

2020-03-19 03:34发布

I am changing a JavaScript file, but it is not showing up in the browser. I cleared browser cache, I purged the cache through wp-admin, I removed the deflate code from .htaccess, but still it doesn't show up.

themes/soundwave/js/prettyPhoto.js?ver=4.2.3

when I add any other number in the ver for example, in the url if I type:

themes/soundwave/js/prettyPhoto.js?ver=4.2.3.1

the change is shown.

2条回答
我想做一个坏孩纸
2楼-- · 2020-03-19 04:12

I had that problem. So at front-end page press Ctrl+U look at the script. If didnt changed, go to functions.php and try to define correct version.(in this exapmle 2.0.0)

wp_enqueue_script( 'theme-global-script', get_stylesheet_directory_uri(). '/js.js?ver=2.0.0', array( 'jquery'), '2.0.0', true );}
查看更多
贪生不怕死
3楼-- · 2020-03-19 04:15

During development, you could avoid the hassle of clearing the browser cache by passing a dynamic variable as the file's version when you enqueue it. For instance, the current time.

wp_enqueue_script( 'prettyPhoto', 'prettyPhoto.js', array(), date("h:i:s") );

查看更多
登录 后发表回答