简体   繁体   English

移动 WordPress 后 jQuery.min.js 无法正确加载?

[英]jQuery.min.js not loading correctly after moving WordPress?

After moving my WordPress site to a new location, I started seeing weird behavior in the WP admin, including:将我的 WordPress 站点移动到新位置后,我开始在 WP 管理员中看到奇怪的行为,包括:

  1. When clicking into a post for editing, a message in red saying "The block editor requires JavaScript. Please enable JavaScript in your browser settings or try the Classic Editor plugin" briefly pops up and then the page goes completely white.单击帖子进行编辑时,会短暂弹出一条红色消息“块编辑器需要 JavaScript。请在浏览器设置中启用 JavaScript 或尝试经典编辑器插件”,然后页面将完全变白。
  2. In my theme options (Divi Extra), the options are all listed but their Enable/Disable toggle buttons are gone.在我的主题选项(Divi Extra)中,所有选项都列出了,但它们的启用/禁用切换按钮不见了。
  3. On certain plugins' settings screens, things like dragging and dropping and clicking on tabs to view additional settings have stopped working.在某些插件的设置屏幕上,拖放和单击选项卡以查看其他设置等操作已停止工作。

When checking the browser console after experiencing these things, I'm seeing a lot of "jQuery.Deferred exception: jQuery (someFunction) is not a function" and corresponding "Uncaught TypeError: jQuery (someFunction) is not a function" for several jQuery functions.在经历这些事情后检查浏览器控制台时,我看到很多“jQuery.Deferred exception: jQuery (someFunction) is not a function”和对应的“Uncaught TypeError: jQuery (someFunction) is not a function”几个jQuery(someFunction)不是一个函数功能。 For example:例如:

jquery.min.js?ver=3.5.1:2 jQuery.Deferred exception: jQuery(...).sortable is not a function TypeError: jQuery(...).sortable is not a function
    at HTMLDocument.<anonymous> (<anonymous>:1:69)
    at e (https://example.com/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:30005)
    at t (https://example.com/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:30307) undefined
    
Uncaught TypeError: jQuery(...).sortable is not a function
    at HTMLDocument.<anonymous> (<anonymous>:1:69)
    at e (jquery.min.js?ver=3.5.1:2)
    at t (jquery.min.js?ver=3.5.1:2)

The reading I've been doing on this makes it sound like the problem is that jQuery functions are being asked to run before they've been defined, and that the solution is to make sure jQuery gets loaded before anything dependant on it does.我一直在做的阅读使听起来问题是jQuery函数在定义之前被要求运行,解决方案是确保jQuery在任何依赖它的东西之前被加载。 That makes sense but when I check the source code, this is right near the top of the page:这是有道理的,但是当我检查源代码时,它就在页面顶部附近:

<script src='https://example.com/wp-includes/js/jquery/jquery.min.js?ver=3.5.1' id='jquery-core-js' type="text/psajs" orig_index="2"></script>

I haven't done anything with wp_enqueue_script () because everything I've read so far makes it seem like that only comes into play if I'm adding some custom js...but the only "custom" javascript on my site is whatever's included with the plugins I've got.我没有对 wp_enqueue_script () 做任何事情,因为到目前为止我所阅读的所有内容似乎只有在我添加一些自定义 js 时才会发挥作用......但是我网站上唯一的“自定义”javascript 是什么包含在我拥有的插件中。 And again, none of this was happening before I moved WordPress.同样,在我移动 WordPress 之前,这一切都没有发生。

What I'm trying to understand specifically is:我想具体了解的是:

  1. Is my problem that jquery.min.js is not loading fast/soon enough on these admin pages?我的问题是 jquery.min.js 在这些管理页面上加载速度不够快吗?
  2. If so, what is the best way to force it to load faster/sooner?如果是这样,强制它更快/更快加载的最佳方法是什么?

Thanks in advance for anyone able and willing to provide assistance!提前感谢任何能够并愿意提供帮助的人!

Turning off a module on my web server called mod_pagespeed_beacon fixed all three of these issues.在我的 web 服务器上关闭一个名为 mod_pagespeed_beacon 的模块解决了所有这三个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM