此為自己翻譯的學習文件,請從此連結參考原作者 David Dias 的 Github 內容
Front-End Checklist 是一份在網站 / HTML 頁面發佈到生產環境前,提供所有需要測試元素的詳細清單
這份清單基於前端開發人員多年經驗的累積,以及其他開源清單而成。
Front-End Checklist 中的所有項目都是大部分專案所必需的,但某些元素可以省略或者不是那麼重要(在管理 Web APP 的情況下,你可能不需要 RSS 訂閱)。我們將元素區分成 3 種等級:
某些資源有特定的圖示,幫助你理解清單上不同類型的內容:
- 📖: 文件或文章
- 🛠: 線上工具 / 測試工具
- 📹: 媒體或視頻內容
Notes: 你可以從 a list of everything 找到
<head>標籤內可操作的內容
<!-- Doctype HTML5 -->
<!doctype html>下方 3 個 meta tags (Charset, X-UA Compatible and Viewport) 需要寫於<head>標籤內的起始處
<!-- 設置文檔的字符編碼 -->
<meta charset="utf-8"><!-- 指示 Internet Explorer 使用最新的渲染引擎 -->
<meta http-equiv="x-ua-compatible" content="ie=edge"><!-- 窗口用於響應式網頁設計 -->
<meta name="viewport" content="width=device-width, initial-scale=1"><!-- 文件標題 -->
<title>Page Title less than 65 characters</title><!-- Meta 描述 -->
<meta name="description" content="Description of the page less than 150 characters">- Favicons:
設置網頁的favicon,確保每個 favicon 被創建且顯示正常,如果只有
favicon.ico,把它放在網站的根目錄下,通常你不需要使用任何標記即可顯示,但最佳做法是以下方範例的方式來連結。現在推薦使用 PNG 格式來取代.ico格式。( 尺寸 : 32 x 32像素 )
<!-- 標準 favicon -->
<link rel="icon" type="image/x-icon" href="https://example.com/favicon.ico">
<!-- 推薦 favicon 格式 -->
<link rel="icon" type="image/png" href="https://example.com/favicon.png"><!-- Apple Touch Icon -->
<link rel="apple-touch-icon" href="/custom-icon.png"><!-- Microsoft Tiles -->
<meta name="msapplication-config" content="browserconfig.xml" />browserconfig.xml 文件至少需含以下 xml 標記:
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="small.png"/>
<square150x150logo src="medium.png"/>
<wide310x150logo src="wide.png"/>
<square310x310logo src="large.png"/>
</tile>
</msapplication>
</browserconfig><!-- 有助於防止重複內容的問題 -->
<link rel="canonical" href="http://example.com/2017/09/a-new-article-to-red.html"><html lang="en"><html dir="rtl"><link rel="alternate" href="https://es.example.com/" hreflang="es">📖 About conditional comments (Internet Explorer) - MSDN - Microsoft
強烈推薦 Facebook OG 和 Twitter Cards ,如有特定需求也可使用其他社交媒體標籤以確保功能顯示正常
- Facebook Open Graph:
確保所有 Facebook Open Graph(OG)都經過測試,沒有錯誤或漏掉信息。圖片至少需要 600 x 315 像素,建議使用 1200 x 630 像素。
<meta property="og:type" content="website">
<meta property="og:url" content="https://example.com/page.html">
<meta property="og:title" content="Content Title">
<meta property="og:image" content="https://example.com/image.jpg">
<meta property="og:description" content="Description Here">
<meta property="og:site_name" content="Site Name">
<meta property="og:locale" content="en_US">
- 📖 A Guide to Sharing for Webmasters
- 🛠 Test your page with the Facebook OG testing
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@site_account">
<meta name="twitter:creator" content="@individual_account">
<meta name="twitter:url" content="https://example.com/page.html">
<meta name="twitter:title" content="Content Title">
<meta name="twitter:description" content="Content description less than 200 characters">
<meta name="twitter:image" content="https://example.com/image.jpg">
- 📖 Getting started with cards — Twitter Developers
- 🛠 Test your page with the Twitter card validator
-
Error pages:
存在 404 和 5xx 錯誤頁面。 5xx 錯誤頁面需要集成其 CSS(當前服務器上無法外部調用)
-
Noopener:
如果你使用
target="_blank"外部連結,你的連結應包含屬性rel="noopener"來避免釣魚攻擊。如果你需要支援舊版 firefox ,使用rel="noopener noreferrer"
-
Desktop Browsers:
所有頁面於桌機瀏覽器作測試 ( Safari, Firefox, Chrome, Internet Explorer, EDGE... )
-
Mobile Browsers:
所有頁面於行動裝置瀏覽器作測試 ( Native browser, Chrome, Safari... )
Notes: 大部分前端開發人員都會參考 CSS guidelines 和 Sass Guidelines 。如果你對 CSS 屬性有疑問,可以訪問 CSS Reference。
- Responsive Web Design:
網站使用響應式設計
- CSS Print:
提供列印模式下的 CSS 樣式呈現,確保每個頁面都顯示正常
- Preprocessors:
你的頁面有使用 CSS 預處理器 ( 推薦使用 Sass )
- Unique ID:
確保每個頁面中的 ID 都是唯一的
- Reset CSS:
使用最新的 CSS reset ( reset, normalize 或者 reboot ),如使用 Bootstrap 或 Foundation 等的 CSS 框架,框架本身已包含 reset 設置
- 📖 Reset.css
- 📖 Normalize.css
- 📖 Reboot
<div id="js-slider" class="my-slider">
<!-- Or -->
<div id="id-used-by-cms" class="js-slider my-slider">- CSS embed or line:
避免使用內嵌或行內 CSS : 僅用於有必要的時候 ( 例 : slider 的 background-image, CSS critical 等 )
- Vendor prefixes:
使用供應商的 CSS 前綴,讓瀏覽器支援兼容性。
- Concatenation:
CSS 文件合併成一個文件 ( 不適用於 HTTP/2 )
- Minification:
所有 CSS 文件作最小化壓縮
- Non-blocking:
避免因 CSS 文件阻塞導致花更多時間載入 DOM
Notes: 想了解更完整的圖片優化內容,請查看 Addy Osmani 的 Essential Image Optimization
- 🛠 Imagemin
- 🛠 Use ImageOptim to optimise your images for free.
- Retina:
提供x2 或 3x 的圖像以支持視網膜顯示
- Sprite:
小圖片統一存成一個 sprite 檔 ( icons 可統一存成一個 SVG sprite )
- Width and Height:
所有
<img>標籤有設定 width 和 height ( 不含單位 px 或 % )
Note: 許多開發人員認為設定圖片寬高會與響應式設計不兼容,但實際上不是這樣。
- Alternative text:
所有
<img>應有替代文字 ( alt ) 來描述圖片內容 - Lazy loading:
圖片使用 lazyloaded ( 也應提供 noscript 當作備案 )
- JavaScript Inline:
避免使用行內 JavaScript ( 與 HTML 寫在一起 )
- Concatenation:
合併 JavaScript 文件
- Minification:
JavaScript 文件最小化壓縮 ( 可於檔名加入後綴
.min)
- JavaScript security:
Guidelines for Developing Secure Applications Utilizing JavaScript*
📖 Cross-Site Request Forgery (CSRF) Prevention Cheat Sheet - OWASP
-
Lazy loading:
圖片,腳本和 CSS 需要 lazy loaded 以改善當前頁面的響應時間 ( 請見各部分的詳細說明 )
-
Cookie size: 如果使用 Cookie,請確保每個 Cookie 不超過 4096 個字節,且域名下不超過 20 個 cookie
<link rel="dns-prefetch" href="https://example.com"><link rel="preconnect" href="https://example.com"><link rel="prefetch" href="image.png"><link rel="preload" href="app.js">Notes: 你可以參考播放清單 A11ycasts with Rob Dodson 📹
📹 Why headings and landmarks are so important -- A11ycasts #18
- Role banner:
<header>有role="banner"屬性 - Role navigation:
<nav>有role="navigation"屬性 - Role main:
<main>有role="main"屬性
- Keyboard navigation:
僅用鍵盤以可能出現的操作順序測試你的網站,確保所有互動元素都可訪問及使用
- Screen-reader:
所有頁面經過螢幕閱讀器的測試 ( VoiceOver, ChromeVox, NVDA or Lynx )
- Focus style:
如果 focus 被禁用,使用 CSS 的可見狀態替代
- Google Analytics:
安裝 Google Analytics 且正確配置
- Headings logic:
標題文字有助於了解當前頁面中的內容
- sitemap.xml:
有 sitemap.xml 檔,並提交給 Google Search Console ( 以前的 Google 網站管理員工具 )
- robots.txt:
The robots.txt 沒有阻擋網頁被搜索
- 🛠 Test your robots.txt with Google Robots Testing Tool
- 📖 Introduction to Structured Data - Search - Google Developers
- 🛠 Test your page with the Structured Data Testing Tool
The Front-End Checklist 也提供其他語言版本,感謝所有的翻譯者!
- 🇯🇵 Japanese: miya0001/Front-End-Checklist
- 🇪🇸 Spanish: eoasakura/Front-End-Checklist-ES
- 🇨🇳 Chinese: JohnsenZhou/Front-End-Checklist
- 🇰🇷 Korean: kesuskim/Front-End-Checklist
- 🇧🇷 Portuguese: jcezarms/Front-End-Checklist
如果想顯示你有遵循前端清單的規定,請將此徽章放在 README 文件上!
[](https://github.com/thedaviddias/Front-End-Checklist/)透過 issue 或 pull request 來建議更改或添加內容
Front-End Checklist 由兩個分支組成 :
該分支包含自動反映在 Front-End Checklist 網站上的README.md文件
這個分支用於對結構及內容進行一些重大更改。最好使用主分支來修復小錯誤或添加新項目
查看所有 contributors
如果你有任何疑問或建議,可透過 Gitter or Twitter 與我聯繫 :



