开发者

Dojo Layers best practice

开发者 https://www.devze.com 2022-12-13 08:04 出处:网络
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

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 woul开发者_开发知识库d 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消