tags:

views:

136

answers:

1

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?

I hope this isn't too subjective 0_o

A: 

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.

peller
Cheers peller, I have decided to make a core layer and load the rest ad-hoc.With less than a 100 users and LAN speeds it wasn't going to be make or break but no reason not to do it right :)
piddl0r