YUI 对话框:实例化一个并显示/隐藏多次?或者每次都实例化一个新的?

发布于 2024-08-19 08:41:36 字数 161 浏览 2 评论 0原文

如果我使用 YUI 来显示一个对话框,我可能希望在一个页面中出现五次,那么最好:

A) 实例化一个对话框,然后多次显示和隐藏它?或者

B)每次显示时都实例化一个新的,然后将其丢弃?

第一个选项似乎会更快。第二种选择似乎需要更少的资源。

想法?

If I was using the YUI to show a dialog which I might want to appear, say, five times in the course of a page, would it be better to:

A) Instantiate one, and then show and hide it several times? or

B) Instantiate a new one each time it's to be displayed, then dispose of it?

First option seems like it'd be faster. Second option seems like it'd require fewer resources.

Thoughts?

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

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

发布评论

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

评论(1

魂ガ小子 2024-08-26 08:41:36

如果是我,我会实例化一个并多次展示。

随着时间的推移,您将节省更多资源。当您比较按需创建新对话框所需的资源时,您所说的在内存中保存对话框的资源很小。您的用户还会注意到性能的一小部分提升(考虑到按需创建的时间与使用已有可用的时间相比)。

If it were me, I would instantiate one and show it several times.

You'll save more resources over time. The resources you're talking about to hold a dialog in memory are small when you compare the resources it takes to create new ones on demand. You're users will also notice a small performance gain (given the time to create on demand versus using one that is already available).

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