我应该内联CSS&吗?JS在移动网站上节省带宽? [英] Should I inline CSS & JS in mobile sites to save bandwidth?

查看:54
本文介绍了我应该内联CSS&吗?JS在移动网站上节省带宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有理由不内联CSS&JS当我建立一个仅限移动设备的网站时,可以节省带宽吗?

Is there a reason not to inline CSS & JS when I make a mobile-ONLY site, to save bandwidth?

推荐答案

内联所有内容都有不同的效果:

In-lining everything has different effects:

  • 减少请求数量-但增加HTML文件大小
  • 增加的HTML文件大小-加载时间大大增加
  • 不缓存-您失去了一个很好的机会
  • 维护就像地狱一样-除非您在开发过程中进行内联

一个不错的博客文章,您可以阅读-为什么内联一切并不是答案他建议在那里仅内嵌非常小的文件(小于1KB)

A good blog post you can read - Why inlining everything is not the answer There he recommends only to inline very small files (less than 1KB)

顺便说一句,为什么不进行内联-Google在其主页上进行了内联.任何拥有查看源"的人都可以看到Google.但仍然是您的选择.
如果您仍在考虑减少HTTP请求的数量,那么最好使用构建工具来自动进行内联.否则,您将必须经历维护地狱".

Hey by the way, why not inline -- Google does it in their homepage. Anyone who has 'View-ed Source' Google has seen it. But still its your choice.
If you are still thinking to reduce the number of HTTP requests then it is better to use a build tool to do the inlining autonomously. Otherwise you'll have to go through the 'maintenance hell'.

这篇关于我应该内联CSS&吗?JS在移动网站上节省带宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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