Posts
All the articles I've posted.
-
浏览器存储
cookie,localStorage,sessionStorage,indexDB 特性 cookie localStorage sessionStorage indexDB 数据生命周期 一般由服务器生成,可以设置过期时间 除非被清理,否则一直存在 页面关闭就清理 除非被清理,否则一直存在 数据存储大小 4K 5M 5M 无限 与服务端通信 每次都会携带在 header 中,对于请求性能影响 不参与 不参与 不参与 从上表可以看大,cookie 已经不建议用于存储。如果没有大量数据存储需求的话,可以使用 localStorage 和 sessionStorage 。对于不怎么改变的数据尽量使用 localStorage 存储,
at 07:08(Updated) -
浏览器渲染机制
渲染流程 浏览器的渲染机制一般分为以下几个步骤: 处理 HTML 并构建 DOM 树 处理 CSS 构建 CSSOM 树 将 DOM 树与 CSSOM 树合并成一个渲染树 根据渲染树来布局,计算每个节点的位置 调用 GPU 绘制,合成图层,显示在屏幕上 在构建 CSSOM 树时,会阻塞渲染,直到 CSSOM 树构建完成。并且构建 CSSOM 树是一个十分消耗性能的过程,所以应该尽量保证层级扁平,减少过度层叠,越是具体的 CSS 选择器,执行速度越慢 当 HTML 解析到 script 标签时,会暂停构建 DOM,完成后才会从暂停的地方重新开始。也就是说,如果你想首屏渲染的越快,
at 07:04(Updated) -
前端安全
XSS XSS(Cross-site scripting) 是一种网站应用程式的安全漏洞攻击,是代码注入的一种。它允许恶意使用者将程式代码注入到网页上,其他使用者在观看网页时就受到影响。这类攻击通常包含了 HTML 以及使用者端脚本语言 XSS 攻击分为三种:反射型,存储型,DOM-based 攻击方式 XSS 通过修改 HTML 节点或者执行 JS 代码来攻击网站 <!-- http://wwww.xxx.com?name=<script>alert(1)</script> --> < div >{{ name }}</ div > 上述 URL 输入可能会将 HTML 改为 <div><script>alert(1)
at 06:43(Updated)