minw
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Ch07. TTI (time to interactive) 互動準備時間 ## 簡介 了解網頁何時可以互動,讓使用者可以不用等待太久即可對網頁進行操作。 ### 定義 ![](https://web-dev.imgix.net/image/admin/WZM0n4aXah67lEyZugOT.svg) - 先算 FCP (first content painting): 參考第五章 - FCP 向右搜尋找到至少 5sec 的 quiete window 時間段: - 沒有長任務(50ms 以上的是長任務) - 代表 main thread 能夠在 100ms 內給予回應,所以每一個任務要保持在 50ms 以內,如果超過就是長任務,也會讓 main thread 沒辦法在 100ms 內給予回應,看起來就會有點卡。 - 不超過兩個 GET request - 代表可以供互動的關鍵 JavaScript 的載入完成時間點 - 💡 會排除 GET Request 以外的類型是因為,通常是通過 GET 來請求資源 [^4][^6] - 🤔 只剩下兩個 request,代表子資源已經載入完畢開始進入關鍵 JavaScript 的載入狀態,且通常在網路緩慢的情況下要 5 秒。 - Lai: [html - Max parallel HTTP connections in a browser? - Stack Overflow](https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser) - 往左回推找最後一個長任務的結束時間,即為 TTI 「時間點」 - 沒有找到則是一路到 FCP 尾為 TTI 「時間點」 - 💡 指標可能有的問題 [^5]: - 可能會讓一些非關鍵 JavaScript 的網頁在指標上表現不佳,但什麼算是非關鍵 JavaScript ? 只能有一個嗎? - 這一個指標是回推而不是即時,如果提前終止的網站就收不到此數據,提前終止與可互動性,是不是這個指標應該要考量的範圍? ![](https://web-dev.imgix.net/image/admin/I7HDZ9qGxe0jAzz6PxNq.png?auto=format&w=845) [^4]: [WICG/time-to-interactive: Repository for hosting TTI specification and discussions around it.](https://github.com/WICG/time-to-interactive) WICG 是 W3C 下孵化新的網站點子的單位 [^5]: [Justify decision of Time to Interactive · Issue #2 · WICG/time-to-interactive](https://github.com/WICG/time-to-interactive/issues/2): 覺得觀點很有趣,指標要思考的是會鼓勵更多什麼樣的網站誕生。 [^6]: [HTTP Archive: Loading Speed](https://httparchive.org/reports/loading-speed#ttci) ## 測量與評估 ![](https://i.imgur.com/ezpVeje.png) - TTI 是在模擬環境下測量的指標,可以透過 lighthouse 測量 - 💡 在模擬環境比較適合,是因為如果實際測量,使用者提前互動可能會影響到這個時間點 [^1] - 如果 TTI 時間點往後延,則會影響到 FID (First Input Delay) 而有可能的互動性問題,作者建議要壓在 5 秒內。 - 💡 為什麼建議 5 秒應是來自於 PR 50 的結果,light house 在 TTI 「分數」計算會參考 HTTP Archive(目前理解成盡可能收集所有網站的一個開源計畫,內含各種指標的計算結果)的資料,取秒數的 PR 值即為分數。 [^2] 其中 5 秒在分數中約中心位置(橘色分數的中間)。 [^1]: [Time to Interactive 可交互时间 (TTI)](https://web.dev/tti/) [^2]: [Time to Interactive - Chrome Developers](https://developer.chrome.com/docs/lighthouse/performance/interactive/#how-lighthouse-determines-your-tti-score) ## 優化方向 - 目前大多採以 FID, TBT 來改善載入互動性,而非 TTI - 💡 TTI 衡量同秒數的體驗效果可能截然不同 [^3] e.g. 10 秒鐘內 3 個 51 ms 任務 vs 單個 10s 任務,TBT 分別是 3ms vs 9950 ms,但 TTI 都是 10s - 🤔 FID 也是衡量互動,但定位有別於 TBT 與 TTI 的指標,應該是因為這個指標是需要實際測量的結果,可以與實驗室測試的指標互補。 - 優化方向 - 縮短主任務時間 - 減少不必要的程式碼 - 減少不必要的網路請求 [^3]: [Total Blocking Time 总阻塞时间 (TBT)](https://web.dev/tbt/#tbt-%E4%B8%8E-tti-%E6%9C%89%E4%BB%80%E4%B9%88%E5%85%B3%E7%B3%BB%EF%BC%9F) ## Review - 指標的定義? - 指標的定位是什麼? - 是個好指標嗎?如果不好有替代指標嗎?

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully