使用站点范围与本地页面脚本时可能存在 JavaScript 框架版本冲突

发布于 2024-08-21 00:58:36 字数 415 浏览 5 评论 0原文

我认为这对于任何 JavaScript 框架来说都是一个问题。

我在网站的部分页面上使用 MooTools。在某些页面上,脚本已有 2 年历史。当新页面需要 MooTools 时,我通常会下载最新版本,以避免因过去的错误而可能出现的问题并利用任何新功能。

这工作得很好,因为我的旧页面仍然可以工作,而我的新页面有最新和最好的。

最近,我想在网站所有页面上共享的页面元素上使用 MooTools。就像网站标题或导航一样。

我还没有这样做,但我假设拥有站点范围的 MooTools 版本会与旧页面上使用的现有版本发生冲突。

我讨厌整个网站都使用一个版本,并且只有在测试了所有旧页面以确保它们不会因新版本而中断时才进行升级。

问题是:我有什么选择?你们在这项工作中使用了什么解决方案?是否有允许两个版本在同一页面中共存的功能?

I assume this would be an issue with any JavaScript framework.

I use MooTools on allot of the pages on my site. On some pages the scripts are 2 years old. When a new page needs MooTools I usually download the latest version to avoid any possible hang-ups with past bugs and to make use of any new features.

This has worked fine as my older pages still work and my new pages have the latest and greatest.

Recently I've wanted to use MooTools on page elements that are shared on all pages of the site. Like the site header or navigation.

I have not done this yet but I assume that having a site-wide version of MooTools will conflict with existing versions in use on older pages.

I'd hate to be committed to one version for the whole site, and only upgrading when I've tested all the older pages to ensure they didn't break with a new version.

Questions are: What options do I have? What solutions have you guys used that work? Is there a feature that allows for two versions to coexist on the same page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2024-08-28 00:58:36

如果我必须在整个站点范围内提供任何给定库的多个版本,我会觉得出了严重的问题。到目前为止,我已经成功地避免了这种情况,即使对于非常(非常)大的 Web 应用程序也是如此。

到了升级的时候,你就升级。如果不是,您可以继续使用 back-rev 库。这就是我熟悉的任何专业软件项目的一般工作方式。我确信存在例外,但我想说,保留和提供多个副本/版本永远都不是理想的情况。

[编辑]顺便说一句,这实际上与多组件服务器端系统或老式客户端服务器系统的类似问题没有什么不同。

[另一个编辑] 请注意,您的客户将必须在其浏览器缓存中维护您的库的单独副本,并且当他们从一个页面跳到另一个页面时,当他们在长时间缺席后访问时,他们将一直拉下新副本(并且换句话说,缓存是旧的)。只需一份副本,他们每次访问最多只需下载一次,如果您利用 Google for jQuery 等工具,那就更好了。

I would feel like something had gone really badly wrong if I had to serve up more than one version of any given library site-wide. So far I've been successful in avoiding that, even for a very (VERY) large web application.

When it's time to upgrade, you upgrade. When it's not, you stick with a back-rev library. That's the way things work in general in any professional software project I'm familiar with. I'm sure there are exceptions, but I would say that keeping and serving multiple copies/versions is never a desirable situation.

[edit] by the way this really isn't that different from similar issues with multi-component server-side systems, or old-school client-server systems.

[another edit] Note that your clients will have to maintain separate copies of your library in their browser caches, and as they hop from page to page they'll be pulling down new copies all the time when they visit after a long absence (and the cache is old, in other words). With just one copy, they only have to download it at most once per visit, and it's even better if you leverage something like Google for jQuery, or whatever.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文