Understanding Web Standards: A Comprehensive Guide

This article provides a comprehensive overview of Web standards, explaining their significance, key organizations like IETF, Ecma, and W3C, and their roles in shaping the modern web.

ByteFE
ByteFE
ByteFE
Understanding Web Standards: A Comprehensive Guide

Web 标准是构成 Web 基础、运行和发展的一系列标准的总称。如果把前端开发人员比喻成“孙悟空”,那么 Web 标准就是“如来佛的手掌”。可以毫不夸张地说:对前端从业者来说,Web 标准意味着能力,代表着舞台,象征着空间,指引着发展。

Web 标准并不是由一家标准组织制定,涉及 IETF、Ecma、W3C 和 WHATWG 等。本文按 Web 标准组织分别简述相关 Web 标准,为前端学习 Web 标准提供指导。

IETF :IETF,全称 Internet Engineering Task Force(互联网工程任务组),成立于 1986 年。Internet 其名的 TCP/IP 协议由 IETF 标准化。

1991 年,Web 发明人 Tim Berners-Lee 总结了其 Web 服务器和浏览器中实现的 HTTP 协议,也就是 HTTP/0.9: https://www.w3.org/Protocols/HTTP/AsImplemented.html

HTTP 0.9 全文不到 700 个单词,定义了最简单的浏览器与服务器通信获得 HTML 页面的协议。这个协议只定义了 GET 请求。

随着 Web 的迅速流行,很多 Web 服务器在 0.9 版基础上增加了扩展。为了把这些扩展及时记录下来,IETF 成立 HTTP Working Group(HTTP WG)着手制定 HTTP/1.0。1996 年 5 月,IETF 发布了一份 RFC(Request for Comments,征求意见稿):RFC 1945。IETF 的 RFC 可以接受为正式标准,也可以作为参考文档。RFC 1945 就是一份参考文档(也就是 HTTP/1.0): https://tools.ietf.org/html/rfc1945

HTTP/1.0 增加了 HEAD 和 POST 方法。增加了可选的 HTTP 版本号。增加了 HTTP 头部字段描述请求和响应。增加了 3 位数的响应码(1xx 保留,2xx 成功,3xx 重定向,4xx 客户端错误,5xx 服务器错误。)HTTP/1.0 已经达到 20000 单词。

仅仅 9 个月后,1997 年 1 月 HTTP/1.1 就发布了。HTTP/1.1 很大程度上也是对 HTTP/1.0 的改进,增加了持久连接、强制服务器头部、更好的缓存和分块编码。为 Web 的发展奠定了基础。

1999 年 5 月被更新版替代。2014 年 5 月再次被更新。每次更新,之前的版本就废弃了。HTTP/1.1 已经长达 305 页,100000 单词。

HTTP/1.1:

https://tools.ietf.org/html/rfc2068

https://tools.ietf.org/html/rfc2616

https://tools.ietf.org/html/rfc7230

https://tools.ietf.org/html/rfc7235

HTTP 最初是纯文本协议。HTTP 消息是明文发送的。可以被任意截获和查看。HTTPS 通过使用 TLS(Transport Layer Security)协议对传输消息进行加密

The Transport Layer Security (TLS) Protocol Version 1.3: https://tools.ietf.org/html/rfc8446

HTTP/1.1 是纯文协议,解析不便,而且一个连接只能请求一个资源。随着 HTTP 请求量越来越大,这种低效越来越明显。尽管人们想出各种方案来提升效率,比如静态资源服务器分片、合并请求,但效果有限,而且会带来新问题。

HTTP/2 是对谷歌 SPDY 的标准化。包括多路利用的字节流、请求优化级和 HTTP 头部压缩。2012 年,HTTP Working Group 注意到 SPDY 的成功,提议制定新版本的 HTTP。2015 年 5 月,HTTP/2 也就是 RFC 7450 被批准为正式标准: https://tools.ietf.org/html/rfc7540

因为 HTTP/2 是基于 SPDY 的,在此之前,很多浏览器其实已经支持 HTTP/2(Firefox、Chrome、Opera),2015 年年底前所有浏览器都支持 HTTP/2(Internet Explorer 11、Edge、Safari)。

目前 HTTP/2 通信已经占全球 43.8%( https://w3techs.com/technologies/details/ce-http2 )。

Ecma

Ecma International 成立于 1961 年,C#、Dart 语言由该组织标准化。当然,JavaScript 也是由 Ecma 标准化的。TC39 负责 ECMA-262,即 ECMAScript 标准的制定。

1997 年 6 月:ECMA-262 1st edition(110 页)

1998 年 8 月:ECMA-262 2nd edition

1999 年 12 月:ECMA-262 3rd edition

ECMA-262 4th edition:不存在

2009 年 12 月:ECMA-262 5th edition(252 页)

2011 年 6 月:ECMA-262 5.1 edition

2015 年 6 月:ECMA-262 6th edition(566 页)

2016 年 6 月:ECMA-262 7th edition(556 页)

2017 年 6 月:ECMA-262 8th edition(885 页)

2018 年 6 月:ECMA-262 9th edition(805 页)

2019 年 6 月:ECMA-262.pdf(764 页)

历史版本: https://www.ecma-international.org/publications/standards/Ecma-262-arch.htm

当前版本: https://www.ecma-international.org/publications/standards/Ecma-262.htm

W3C

W3C,即 World Wide Web Consortium(万维网联盟),1994 年在美国 MIT 成立,是 Web 标准的主要制定者。目前有效的正式推荐标准有近 300 个(293 个):

The Latest Recommendation:

https://www.w3.org/TR/?status=rec&version=latest

概览

BOM :BOM(Browser Object Model,浏览器对象模型)HTML5 规范中有一部分涵盖了 BOM 的主要内容,因为 W3C 希望将 JavaScript 在浏览器中最基础的部分标准化。

window 对象,也就是 ECMAScript 中定义的 Global 对象。网页中所有全局对象、变量和函数都暴露在这个对象上。

location 对象,通过

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ByteFE
Written by

ByteFE

Cutting‑edge tech, article sharing, and practical insights from the ByteDance frontend team.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.