Dojo 层最佳实践

发布于 2024-08-13 11:04:26 字数 217 浏览 7 评论 0原文

我当前的项目用户群很小,几乎所有客户端都与网络服务器位于同一个 LAN 上,因此性能不会真正受到阻碍,但我很容易养成坏习惯,所以我想习惯正确地做事。

我正在考虑制作一个通用的“站点”层,其中包括常用的需求(主要是表单、对话框和网格),并在需要时添加其他组件(例如图表),即使网格可能不需要每一页。我只会维护一层,但每个请求都会更大。

一个请求有一个稍微臃肿的层还是几个请求有几个小层更好?

My current project has a small user base and nearly all clients will be on the same LAN as the webserver so performance won't really be hindered but I'm a sucker for picking up bad habits so I want to get used to doing it right.

I was thinking make a generic 'site' layer which would include the commonly used requires (mainly form, dialog & grid) and add the other components (such as charts) when required, even though the grid for example may not be required for every page. I would only have one layer to maintain at way but each request is going to be bigger.

Is it considered better to have one request with a slightly bloated layer or a couple of requests with a couple of small layers?

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

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

发布评论

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

评论(1

苦行僧 2024-08-20 11:04:26

像大多数事情一样,这取决于情况。如果您的应用程序仅限于 LAN,那么您不会像那些按字节为其托管付费的人以及在 WAN 上产生显着延迟的最终用户那样关心浪费的字节。如果用户最终可能会导航到包含所有各种组件的页面并最终需要代码,那么您可能会说您在浪费时间来制作图层。您的情况似乎需要权衡,因为您需要预先花费一些额外的下载时间。这要么使初始页面加载速度变慢,要么使后续页面加载速度加快,具体取决于您如何看待它。在 LAN 上,这两种情况都可以忽略不计。

一般来说,最好创建图层,因为可能会在站点上的其他页面或将来的应用程序中重复使用较小的文件(其中可能存在缓存命中),并且还可以最大程度地减少用户下载代码的可能性他们不会访问的页面。维护这些层的成本应该不会太高。

Like most things, it depends. If your app is limited to a LAN, you're not going to care as much about wasted bytes as someone who pays by the byte for their hosting and end users who incur significant latency over a WAN. If the user is likely to end up navigating to a page with all the various components and need the code eventually, you could argue you're wasting your time making layers. It seems the tradeoff in your case is that you're incurring a little extra download time upfront. That either makes the initial page load slower or subsequent pages load quicker, depending on how you look at it. On a LAN that's probably negligible either way.

In general, it is better practice to create layers because of the potential for re-use of the smaller files in other pages or future applications on your site where there might be a cache hit, and also to minimize the possibility that users will download code for pages they won't visit. The cost for maintaining such layers shouldn't be too bad.

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