我删除jquery.min.js wordpress时的问题
我想删除jquery.min.js。因为我不需要。为此,有必要不使用“ wp_deregister_script”。
我还手动添加了主题的JS文件。
<script type='text/javascript' src='http://site/wp-content/themes/mytema/js/scripts.js'></script>
但是,当我手动添加主题的JS文件不起作用。 当我与Chrome检查时,我看到了以下错误。
未介绍的参考:未定义jQuery https://sitet/wp-content/themes/mytema/js/scripts.js:1
不需要参考。现在只有一个JS文件。如何解决此问题?谢谢。
I want to remove jquery.min.js. because I don't need it. For this, it is necessary not to use "wp_deregister_script".
I also added the theme's js file manually.
<script type='text/javascript' src='http://site/wp-content/themes/mytema/js/scripts.js'></script>
but the js file of the theme does not work when I add it manually.
When I checked with Chrome, I saw the following error.
Uncaught ReferenceError: jQuery is not defined
https://sitet/wp-content/themes/mytema/js/scripts.js:1
There is no need for a reference. There is only one js file now. How can I fix this problem? thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很简单。您没有任何jQuery文件,但是代码中想要使用jQuery对象。您要么必须删除包含jQuery的代码,要么必须使用jquery.min.js。
并要手动加入js文件,请关注此 https://developer.wordpress.org/themes/basics/including-css-javascript/
谢谢
This is pretty simple. You have no any jquery file but in code wanted to use the jQuery object. Either you have to remove the code where contain the jQuery or you have to use the jquery.min.js.
And to manually enqueue the js file please follow this https://developer.wordpress.org/themes/basics/including-css-javascript/
Thank you
也许在JS脚本上方包含使用jQuery对象的代码。我建议您检查该部分并使用“ WP_enqueue_script Hook” F插入脚本。
https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/#:~: text = wp_enqueue_scripts;
Perhaps above js script contains a code that uses the jquery object. I recommend that you check that part and use "wp_enqueue_script hook"f to insert the script.
https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/#:~:text=wp_enqueue_scripts%20is%20the%20proper%20hook,enqueuing%20both%20scripts%20and%20styles.