Rule 1: Make Fewer HTTP Requests(Chapter 1 of High performance Web Sites)

本文介绍了几种有效减少网页加载过程中HTTP请求次数的方法,包括使用图像地图(Image Maps)、CSS精灵(CSS Sprites)以及内联图像(Inline Images)。通过这些技巧,可以显著提升网站的加载速度和用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The rules described in later chapters also present guidelines that help reduce the number of
HTTP requests, but they focus primarily on subsequent page views.

Image Maps
ContractedBlock.gifExpandedBlockStart.gifImage Maps
<img usemap="#map1" border=0 src="/images/imagemap.gif">
<map name="map1">
<area shape="rect" coords="0,0,31,31" href="home.html" title="Home">
<area shape="rect" coords="36,0,66,31" href="gifts.html" title="Gifts">
<area shape="rect" coords="71,0,101,31" href="cart.html" title="Cart">
<area shape="rect" coords="106,0,136,31" href="settings.html" title="Settings">
<area shape="rect" coords="141,0,171,31" href="help.html" title="Help">
</map>

CSS Sprites
ContractedBlock.gifExpandedBlockStart.gifCSS Sprites
 1 <style>
 2 #navbar span {
 3 width:31px;
 4 height:31px;
 5 display:inline;
 6 float:left;
 7 background-image:url(/images/spritebg.gif);
 8 }
 9 .home { background-position:0 0; margin-right:4px; margin-left: 4px;}
10 .gifts { background-position:-32px 0; margin-right:4px;}
11 .cart { background-position:-64px 0; margin-right:4px;}
12 .settings { background-position:-96px 0; margin-right:4px;}
13 .help { background-position:-128px 0; margin-right:0px;}
14 </style>

Inline Images
ContractedBlock.gifExpandedBlockStart.gifInline Images
1 <IMG ALT="Red Star"
2 SRC="data:image/gif;base64,R0lGODlhDAAMALMLAPN8ffBiYvWW
3 lvrKy/FvcPewsO9VVfajo+w6O/zl5estLv/8/AAAAAAAAAAAAAAAACH5BAEA
4 AAsALAAAAAAMAAwAAAQzcElZyryTEHyTUgknHd9xGV+qKsYirKkwDYiKDBia
5 tt2H1KBLQRFIJAIKywRgmhwAIlEEADs=">

Combined Scripts and Stylesheets

转载于:https://www.cnblogs.com/zhtf2014/archive/2009/09/25/1574247.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值