JavaScript 最佳实践:如何实现长寿命应用程序(单页 Web 应用程序)?

发布于 2024-10-04 07:37:22 字数 438 浏览 1 评论 0原文

是否有实现长期 JavaScript 应用程序(即由单个页面组成并通过 AJAX 将其他页面加载到内容区域的 Web 应用程序)的最佳实践? (Gmail 就是一个很好的例子。)

我已经阅读了有关优缺点、SEO、性能等的内容(http://stackoverflow.com/questions/1499129/one-page-only-javascript-applications),我'我对如何实现这一点的模式感兴趣。

我想避免使用大型框架(例如 Cappuccino、Echo2、SproutCore、Claypool)。

如何管理动态加载内容,同时维护 URL 的 #link 部分(用于书签)?

不要误会我的意思,我自己有一个如何实现这个的想法,但这个问题之前肯定已经解决了。

有这方面的文章吗?也许是一个小型 JavaScript 库?

谢谢! 标记

Are there any best practices for implementing a long-lived JavaScript app, i.e. a web app that consists of a single page and loads other pages into the content area via AJAX? (Gmail is a good example of this.)

I already read about pro and cons, SEO, performance, etc. (http://stackoverflow.com/questions/1499129/one-page-only-javascript-applications), I'm interested in patterns how to implement this.

I'd like to avoid large frameworks (e.g. Cappuccino, Echo2, SproutCore, Claypool).

How would I manage dynamically loading content while maintaining the #link portion of the URL (for bookmarking)?

Don't get me wrong, I have an idea how to implement this myself, but this problem must have been solved before.

Are there articles on this? Maybe a tiny JavaScript library?

Thanks!
Mark

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

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

发布评论

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

评论(3

旧夏天 2024-10-11 07:37:22

我发现 JQuery Address http://www.asual.com/jquery/address/ 非常简单来设置。 $.address.change() 让您知道何时点击了某些内容(也适用于来回),您只需解析 self.location.hash 并构建您的应用程序从那里。如果您可以使用 JQuery 进行处理,它看起来也足够轻量。

I found JQuery Address http://www.asual.com/jquery/address/ extremely easy to set up. $.address.change() let's you know whenever something was clicked (works with back and forth as well) and you just parse self.location.hash and build your app from there. It seems lighweight enough as well, if you can handle using JQuery.

乙白 2024-10-11 07:37:22

这里有一篇文章可以帮助您解决历史书签问题:http: //codinginparadise.org/weblog/2005/09/ajax-dhtmlhistory-and-historystorage.html。它已经很旧了,但解决方案仍然有效。

我使用这个“长寿”应用程序制作了几个应用程序,您应该考虑的一件事是 IE 泄漏内存的倾向。

我还建议您使用 JS 库(例如 JQuery)来帮助您使用 AJAX 和 DHTML。

Here is an article to help you with the History bookmarks problem: http://codinginparadise.org/weblog/2005/09/ajax-dhtmlhistory-and-historystorage.html. It's quite old, but the solution still works.

I made several apps using this "long lived" apps, and one thing you should take into account is IE's tendency to leak memory.

I would also recommend you to use a JS library, like JQuery to help you with the AJAX and DHTML.

伪装你 2024-10-11 07:37:22

听说过 JavaScript PushState 吗?

http://badassjs.com/post/840846392 /location-hash-is-dead-long-live-html5-pushstate

它的目的是替换 location.hash

Heard about javascript pushstate?

http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate

It's meant to replace location.hash

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