Is there a maximum size that web pages should be kept under?

后端 未结 6 1169
轻奢々
轻奢々 2021-01-07 19:27

When I say size I\'m talking about bytes not pixels.

I\'m curious if there is any consensus on what the maximum size should be for various categories. Specifically

6条回答
  •  醉酒成梦
    2021-01-07 19:52

    Depends on the page really. If your page is an informative one, you'll have lots of HTML (text) content. But if your page is more graphical (like a store department page showing images of products), you'll have lots of images.
    Images are much heavier than text (a single image could be 50K, which is like 10 pages of text).
    You also need to consider the size of CSS files, javascripts, etc. But they're cached so they only matter for the initial 'load'.
    Having said that, you could set a target of 100-200k (mixed text/images) max per page. More than that and slower connections will take a while to load.
    Most probably you don't know who's going to visit your page (mobile, broadband or dialup), so you should try to reach a common ground (or design different pages for different targets, but this is a pain to maintain in the long run as your site expands). I think 100-200k is ok for most cases.
    If you have pages that are necessarily big, you can still achieve this, there are several tricks you can use, like image compression (using 90% quality JPGs), javascript/ajax to load content on demand, minifying the files (CSS, javascript), using site compression (gzip), etc.

提交回复
热议问题