大网数据广告活动
网站运营与故障问答

Splitting big CSS file into parts for quicker loading

· 52CE 我爱测

So I have a relatively big CSS file. I thought about doing the following, splitting it to 3 parts: 1st part will have the main selectors that are needed to run on the main page that gets the biggest traffic. 2nd part will have CS…

问题原文

原帖链接 · CamSpy · CC BY-SA 3.0

So I have a relatively big CSS file. I thought about doing the following, splitting it to 3 parts:

  • 1st part will have the main selectors that are needed to run on the main page that gets the biggest traffic.
  • 2nd part will have CSS for the rest of the pages
  • 3rd page will have all the screen size dependent set up intended for mobile devices to have responsive pages

I am running my static files off a CDN and I would put each of these parts to a separate subdomain to have them all downloaded faster than one file.

Do you think this is a good way of doing that?

EDIT: since I didn't make clear, I am using CDN service on subdomains to serve all static content, so there are 5 subdomains that I use and they all are on CDN. Each of them is used to serve a number of files: CSS, JS, JPG, PNG, etc. DNS lookups are being made anyways.

社区高分解答

原帖链接 · John Conde · CC BY-SA 3.0

No. This will not make your site faster and is unnecessary. Multiple HTTP calls slow down your website, not speed it up.

To make your CSS load as fast as possible:

  1. Minify it
  2. Compress it using gzip (mod_deflate)
  3. Serve it from a CDN

Once the browser has the file it will cache it and no more requests will need to be made which is as fast as it gets.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2013-12-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。