最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - WordPress not updating the js file - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Sep 13, 2015 at 9:21 halfer 20.5k19 gold badges108 silver badges201 bronze badges asked Aug 5, 2015 at 13:14 Sandhya NambiarSandhya Nambiar 811 gold badge1 silver badge3 bronze badges 3
  • Goto your frontend and Press Ctrl + U and try to click on your js link to make sure it's not broken. – Indrasinh Bihola Commented Aug 5, 2015 at 13:16
  • How have you added the .js file to your theme? Did you use wp_enqueue_scripts() function ? – Hareesh Sivasubramanian Commented Aug 5, 2015 at 13:23
  • I always have this problem, it is annoying, if I could choose I would stop using WP altogether because of this – user3808307 Commented Mar 20, 2017 at 17:58
Add a ment  | 

2 Answers 2

Reset to default 11

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") );

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 );}
发布评论

评论列表(0)

  1. 暂无评论