gpt4 book ai didi

javascript - 哪个版本的 jQuery 在加载多个库的网站上运行?

转载 作者:行者123 更新时间:2023-11-29 22:26:26 25 4
gpt4 key购买 nike

我正在做一个项目,其中有多个库在头部加载。使用的 CMS 是 WordPress。

通过 wp_head,有一个最新版本 1.7.1 的排队脚本,但就在它下面有一组以 1.4 版本开头的脚本文件。

这是一个简单的可视化流程图:

<head>    
<script jQuery 1.7.1>
<script jQuery 1.4>
<script Colorbox>
[7 more scripts dependent on 1.4 here]
</head>
...
<footer>
<scripts that can use either 1.7.1 or 1.4>
</footer>

我的理解是,由于 jQuery 1.4 低于 1.7.1,它实际上是正在使用的库。

是否可以重新安排脚本,使依赖于 1.4 的脚本只能由 1.4 使用,然后由 1.7.1 使用其余脚本?例如:

<head>    
<script jQuery 1.4>
<script Colorbox>
[7 more scripts dependent on 1.4 here]
<script jQuery 1.7.1>
</head>
...
<footer>
<scripts that can use either 1.7.1 or 1.4>
</footer>

看看我是如何下移 1.7.1 的? 1.7.1 在 1.4 脚本下方的头部位置是否会影响 1.4 脚本?

有没有办法检测整个页面使用的是哪个版本的 jQuery?

最佳答案

请在“那些依赖于 1.4 的那些”中定义那些,只为网站的一部分回退版本绝不是一个好主意。如果是多个网站运行相同的 header ,您可能想尝试在 php(基于数据库)字段中加载并设置需要在其中使用的库。我的建议是,如果您的部分代码确实不适用于新库,请更新该代码。并始终使用最新的 JQuery :)

关于javascript - 哪个版本的 jQuery 在加载多个库的网站上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9137910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com