比较加载CSS内联,嵌入式和外部文件 [英] Comparison of loading CSS inline, embedded and from external files
问题描述
我们可以将CSS编写为以下类型:
- 内嵌CSS
- / li>
- 外部CSS
我想知道每个的利弊。
这是所有的流程中你需要的CSS,因为我看到它。
< h2> 1。 inline css
优点:非常适合快速修复/原型设计和简单测试,无需在.css文档和实际HTML文件。
优点:许多电子邮件客户端不允许使用外部.css引用,因为可能的垃圾邮件/滥用。嵌入可能有帮助。
缺点:填充HTML空间/占用带宽, b
$ b
2。嵌入式css
优点:与原型相同,但更容易剪切出最终原型并放入外部文件
3。外部css
优点:易于在超过1个网页的网站上维护和重复使用。
优点:可缓存=较少带宽=第二页加载后页面呈现速度更快
优点:包括.css的文件可以在CDN上托管,从而对托管HTML页面的防火墙/ web服务器(如果在不同的主机上)提出较少的请求。
可编译,您可以自动从最终版本中删除所有未使用的空间,就像jQuery有开发人员版本和压缩版本=更快下载=更快的用户体验+更少的带宽使用=更快的互联网! (我们喜欢!!!)
缺点:通常从HTML邮件中移除=凌乱的HTML布局。
缺点:每个文件需要额外的HTTP请求=防火墙/路由器中使用更多的资源。
我希望你能使用其中的一些吗?
We can write CSS as the following types:
- Inline CSS
- Embedded CSS
- External CSS
I would like to know pros and cons of each.
It's all about where in the pipeline you need the CSS as I see it.
1. inline css
Pros: Great for quick fixes/prototyping and simple tests without having to swap back and forth between the .css document and the actual HTML file.
Pros: Many email clients do NOT allow the use of external .css referencing because of possible spam/abuse. Embedding might help.
Cons: Fills up HTML space/takes bandwidth, not resuable accross pages - not even IFRAMES.
2. embedded css
Pros: Same as above regarding prototype, but easier to cut out of the final prototype and put into an external file when templates are done.
Cons: Some email clients do not allow styles in the [head] as the head-tags are removed by most webmail clients.
3. external css
Pros: Easy to maintain and reuse across websites with more than 1 page.
Pros: Cacheable = less bandwidth = faster page rendering after second page load
Pros: External files including .css can be hosted on CDN's and thereby making less requests the the firewall/webserver hosting the HTML pages (if on different hosts).
Pros: Compilable, you could automatically remove all of the unused space from the final build, just as jQuery has a developer version and a compressed version = faster download = faster user experience + less bandwidth use = faster internet! (we like!!!)
Cons: Normally removed from HTML mails = messy HTML layout.
Cons: Makes an extra HTTP request per file = more resources used in the Firewalls/routers.
I hope you could use some of this?
这篇关于比较加载CSS内联,嵌入式和外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!