前端性能

JavaScript

在HTML5中如何提高网站前端性能的示例代码分析

24 0

1. 用web storage替换cookiesCookie最大的问题是每次都会跟在请求后面。在HTML5中,用sessionStorage和localStorage把用户数据直接在客户端,这样可以减少HTTP请求的数据量。而且Web storage还提供了API来操作数据,不像cookie,还得自己写。1234567891011121314151617// if localStorage is present, use thatif (('localStorage' in window) && w