@import在CSS中导致额外的http请求? [英] Does @import in CSS result in additional http requests?

查看:272
本文介绍了@import在CSS中导致额外的http请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个电子商务网站,其中有大约8个CSS文件从标题链接 - 导致8个单独的http请求到服务器。我将所有的CSS文件合并为一个大的文件,导致一个67kb(!)文件 - 将我们的css文件的http请求减少到1。

I have an ecommerce site that has about 8 CSS files linked from the header - resulting in 8 separate http requests to the server. I consolidated all the CSS files into 1 big one, resulting in a 67kb (!) file - to cut down the http requests to 1 for our css files.

m找到这个大小一个CSS文件有点难以管理的事实,我在网站上不断执行更新的事实。我担心的是我的用户可能会抓住我在更新的时候看到一个非风格的页面,当一个页面移动到页面 - b / c 67kb仍然需要一个好的2-3秒,它成功地放置在远程服务器之间通过FTP 。

I'm finding this size a CSS file a little unmanageable in light of the fact I'm performing updates on the site constantly. My concern is my users may catch me in the middle of updating and see a NON-styled page when moving from page to page - b/c 67kb still takes a good 2-3 seconds before it is successfully placed on the remote server via FTP.

我的问题是:在这个大型CSS文件中使用@import将文件分解成更小的更容易管理的大小到页面加载时的原始8个http请求?或者是@imports在CSS句柄不同的方式不同?

My question is: does the use of @import within this large CSS file to break up the files into smaller more manageable sizes (within that CSS file) take us back to the original 8 http-requests when the pages is loaded? Or are @imports in CSS handle differently somehow?

推荐答案

是的,你会回到一个请求每个样式表, 。

Yeah you will go back to a request per each stylesheet while using @import.

最好的办法是将css缩小并合并为一个文件进行部署。但您仍然可以使用单独的文件进行开发。

Your best bet is to minify and consolidate the css into a single file for deployment. But you can still develop with seperate files.

这篇关于@import在CSS中导致额外的http请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆