douqufan9148 2013-07-16 07:13
浏览 102
已采纳

如何减少HTTP请求?

I analyzed my site and I found I have a Grade F on Make fewer HTTP requests with this description :

This page has 6 external Java script scripts. Try combining them into > one. This page has 3 external style sheets. Try combining them into > one. This page has 18 external background images. Try combining them > with C SS sprites.

How can I Make fever? How can I combine images using C SS sprites?

  • 写回答

3条回答 默认 最新

  • drymoeuka282427675 2013-07-16 07:23
    关注

    You'll want to look in to preprocessors that make this job a lot easier. Preprocessors are available for javascript external files as well as css (SASS and LESS among others). The alternative is combining the stylesheets yourself, but these programs will automatically do it and some often minify your stylesheets as well to improve speed.

    https://code.google.com/p/jsmake-preprocessor/

    http://sass-lang.com/

    As for the sprite images, depending on your images it could be unrealistic to put them into sprites. It works well for icons and things small in nature, but is a hassle for things like large background images, etc. The reason I say that is because you will have to modify and adjust the sprite every time as opposed to making a simple CSS change. It's a cost / benefit analysis based on how much request time you save.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 链接问题 C++LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接