kentyangfake
    • 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
    # Chrome DevTools & debug ## [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools/) #### Elements Panel Provides a conduit to **directly interact** with the DOM and styling, 可以直接inspect網頁元素for test out and debug structural and aesthetic issues in HTML and CSS. ![](https://i.imgur.com/qmEVWis.png) * Styles tab可以直接修改或套用css參數 * 右鍵 > Edit Text or Edit as HTML 可以修改html內容 * ![](https://i.imgur.com/7q0p81K.png) 滑鼠inspect,快捷:ctrl+shift+c #### Resources Panel Provides a picture of the file structure and all the assets and data being loaded into the browser. From here you can view **details about assets** such as images and videos. You can also inspect data stored in cookies, sessions, local storage, and more. ![](https://i.imgur.com/8Z2DW2c.png) * Local Storage可以create, read, update, or delete any key/value pairs. * 引導到sources panel 檢視細節<br> ![](https://i.imgur.com/NXf13Ua.png)<br> ![](https://i.imgur.com/nIvQLrj.png) #### Sources Panel The Sources panel allows you to make adjustments to your code in real time. You can revert to previous revisions of your changes, or you can save your changes to a file. ![](https://i.imgur.com/yvXJavc.png) * 右鍵 > Save As...: 可以直接把修改好的檔案存下來 * 右鍵 > Local modification: 修改檔案的版本控管 * You can set breakpoints in JavaScript to stop your code from executing. * ![](https://i.imgur.com/CvtZb8g.png) 會在出錯的的方暫停程式 #### Network Panel ![](https://i.imgur.com/P0f3X5P.png) 製作圖表呈現 when assets loaded in, the order in which they loaded, load多久等等 (being accessed with an **HTTP request**). The Network panel is a great tool for investigating front-end *performance issues* and finding parts of the page that can be optimized. * HARD refresh: command+shift+R 重新整理是捕捉網路活動最好的法,若想pull all assets fresh且不使用cached assets的話,要使用強重整. * initiator: 檔案是如何被加載的 * 透明是等待時間,實體是下載時間 ![](https://i.imgur.com/xTXnbe7.png) * 紅線藍線: 藍-HTML下載時間 紅-其他assets下載時間 ![](https://i.imgur.com/a16ERIK.png) * 最下面灰條: requests數量,下載容量大小等等 * status 404 500s等代表加載失敗,可以排除這些元素 * sprite map(其中一種減少http requests的方法) #### Performance Panel Allows you to see how **pages behave over time**. You can profile memory usage, JavaScript events, and rendering performance. For example, if complex effects are impacting the framerate of a page, the Timeline panel can help reveal where and when those issues exist. * optimal frame rate: 60fps以上 #### Profiles Panel Can take snapshots of CPU and memory utilization. This is useful in complex JavaScript applications that can potentially use too much of the processor and memory. In conjunction with the *Performance panel*, it can be useful for tracking down the source of memory leaks and other areas where performance can be improved. * Start Recording 後會create new profile, Stop recording後會揭露有運行的function * heap snapshot: 展示網頁上的JS的memory distribution. #### Audits Panel The Audits panel provides automated suggestions for improving front-end performance. For example, the audits panel might suggest specifying explicit dimensions for images to improve rendering performance. It can also help identify CSS rules that aren’t being utilized. #### Console Panel The Console panel is both a log and a command line tool that allows you to interact with the JavaScript on a page. You can execute existing functions, rewrite variables and functions, or create entirely new code. The console will also JavaScript errors, which is useful for debugging code. * `$()`:select DOM elements on the page * 上鍵: recall previous command * **Console API**: profiling JavaScript code, logging commands, recording the execution time of code, and more. In this video, you’ll learn how to time the execution of a loop. ``` console.time("Loop"); ...loop console.timeEnd("Loop"); ``` #### [Adjusting Settings](https://developers.google.com/chrome-developer-tools/docs/settings) From the Settings window, you can adjust general settings for the DevTools. * Disable cache * Disable JS * log XMLHttpRequests(AJAX) * Override user agent & Device metrics * shortcuts ## Debugging CSS #### Styles pane * 被overriden的propertie會被劃掉(**media query**覆蓋的也會) ![](https://i.imgur.com/vPocKSo.png) * hovering到的style rule會hightlights所有有使用此rule的元素 ![](https://i.imgur.com/U1mEV9O.png) #### [Viewing](https://developer.chrome.com/docs/devtools/css/) Inherited and User Agent Styles ![](https://i.imgur.com/Vm2ghrN.png) * 淺灰色區域: user agent使用的stylessheet(browser內建的) * 深灰色區域: 父層繼承的stylesheet, 取消打勾是取消父層,也會影響其他子元素 * 半透明的properties: non-inheritable property #### Identify and Debug Errors * Overview of **Element tab** and **Style Pane** in DevTools * Identify errors in CSS ![](https://i.imgur.com/i0DNTbA.png) * Visualize and test [element states](https://developer.chrome.com/docs/devtools/css/#pseudostates)(`:hover` `:focus` `:active` etc...) 1. 右鍵啟用hover pseudo-class![](https://i.imgur.com/zJx0H37.png) 2. 或toggle `:hov`![](https://i.imgur.com/MubFQ5w.png) 即可開啟或關閉element states * Add, enable and disable classes ![](https://i.imgur.com/VBUjlxG.png) 即可新增,開啟或關閉element classes **Tips**: 用紅框框出目前debug中的element,新增以下CSS, `.debug{border: 2px solid red;}` toggle `.cls`後增加debug class,結果如下: ![](https://i.imgur.com/zyN9yNs.png) * Copy and [save out](https://developer.chrome.com/docs/devtools/workspaces/) changeds to CSS #### Visualizing the Box Model and Computed styles **Computed pane**: displays the final set of CSS properties the browser is applying to the selected element. It also displays a representation of an element's box model, so you can quickly examine and edit its content, padding, border and margin areas. * Computed value單位是**px**.下圖顯示2.5em換算後為40px ![](https://i.imgur.com/BqRHHhR.png) * Box Model 數值都可編輯 ![](https://i.imgur.com/5m11NUg.png) ## Debugging javaScript 1. Stop execution at a given line 2. Explore values while the app is paused 3. Step through code, line by line 4. Repeat above, Fix bug #### Breaking on Events and Basic Stepping * Overview of **Sources tab** in DevTools 左pane:resources tree. 雲port:How you serving the app,其他的資源 中pane: 檔案內容,刷新載入 右pane: Debug tools * Set an **Event Listener Breakpoint** 勾選event breakpoitn ![](https://i.imgur.com/u0uyC9Q.png) * All variables and values in **current scope** 繼續操作網頁,勾選的event發生時網頁會暫停,畫面如下 ![](https://i.imgur.com/T2d8EVW.png) **e**: event object | [**this**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this) DevTools暫停時其他畫面也會暫停,重新整理頁面 * **Step over** button, seeing code execute line-by-line ![](https://i.imgur.com/WQICZxh.png)Step over, 點擊hightlight下一行code,再點擊會執行,並hightlight下一行code ![](https://i.imgur.com/BXUG6KA.png) 1. viewer會顯示那行code的變數值 2. 或是hover到var,來顯示內容 * Changing value of a variable while program is paused event暫停處,檢查變數值(有誤) ![](https://i.imgur.com/SHWWFKm.png) 切換console修改(等於重寫暫停的地方) ![](https://i.imgur.com/aimjm84.png) 切回Sources tab > ![](https://i.imgur.com/9kzcbNd.png)step下一行會refresh變數值 ![](https://i.imgur.com/xdjikht.png) ![](https://i.imgur.com/9kzcbNd.png)step往下執行看看有沒有debug成功 ![](https://i.imgur.com/HHg5d3X.png) 成功後把修改好的code改回檔案裡 * **Disable/enable** all breakpoints ![](https://i.imgur.com/WaOqLEG.png)啟動/關閉breakpoint #### Basic and Conditional Line Breakpoints 1. 直接點選想設定Breakpoints的line![](https://i.imgur.com/cCeFMFp.png) 2. ![](https://i.imgur.com/Etb4dma.png)會直run程式碼,直到Breakpoint暫停 ![](https://i.imgur.com/7uYYADg.png) 3. 若在loop打點,按![](https://i.imgur.com/Etb4dma.png)loop會再執行一次後又暫停(圖中Scope block顯示loop到第0個li) * 設定特定condition條件 1. 在想設定Breakpoints的line右鍵 > Add conditional breakpoint... ![](https://i.imgur.com/9Rista0.png) 2. 輸入條件![](https://i.imgur.com/jHVEqQy.png) 3. ![](https://i.imgur.com/Etb4dma.png)(圖中第4個li被highlighted) ![](https://i.imgur.com/HeaOWzh.png) 4. 可重新編輯條件![](https://i.imgur.com/DsIPcUV.png) #### Debugging Functions 1. 選取event breakpoint,操作網頁觸發event 2. 標記function行位置 > ![](https://i.imgur.com/bgJFLTG.png)到function暫停 3. 使用step into進入function * **Step into**![](https://i.imgur.com/evNit0y.png) : 因![](https://i.imgur.com/OTtB3Xj.png)會跳過function,故使用![](https://i.imgur.com/evNit0y.png)來進入function code檢視 ![](https://i.imgur.com/nmm0N8n.png) * **Call Stack window** 顯示哪些function在執行,點選function可檢視**1.此function在哪裡** / **2.此function Scope裡有哪些變數** ![](https://i.imgur.com/EmYeiFW.png) Call Stack概念 ![](https://i.imgur.com/lQCwrg4.gif) * **Step out** ![](https://i.imgur.com/BLNQgMU.png) : 完成current function並跳回call他的function, current function會被call stack移除 #### Debugging Exception Errors ![](https://i.imgur.com/SN06uHt.png) 1. 錯誤發生通知 2. 會跳出console(同console tab) **hotkey**: esc 3. 點選連結會進入Sources tab 4. 開啟Pause exceptions後refresh頁面 * **Pause exceptions** ![](https://i.imgur.com/3KU2Q0Y.png) : 在error發生前停止程式,可以檢查造成error的state #### Breaking on DOM Changes and Watch Expressions * DOM-change breakpoints 1. 在想檢視的dom element按右鍵 ![](https://i.imgur.com/YuFazet.png) **subtree modifications** : DOM element內的elements被改變 **attribute modifications** : 例如增加或改變className **node removal** : DOM element被移除 2. 設定後會有藍點點 ![](https://i.imgur.com/HyM7uV0.png) * Watch expressions 叫DevTools盯好指定value的變化 ![](https://i.imgur.com/x6XEsuJ.png) refresh頁面操作網頁,在watch window裡檢視value的變化 ![](https://i.imgur.com/pUCDbWj.png) #### 快取&重新整理 ![](https://i.imgur.com/S6lWnos.png) * Preserve log * Disable cache #### 切換Device類型 ![](https://i.imgur.com/ZgSkcxD.png) #### 長按重新整理3秒 ![](https://i.imgur.com/Ye3ky4S.png) #### Wifi 內網 ip ![](https://i.imgur.com/CMFVV48.png) live server開在port:5500`http://[LOCAL HOST]:5500`: ip輸入在這可以給別人測試 [手機測試教程](https://mocationer.com/live-server-phone) ## React 可以觀察state變化 ![](https://i.imgur.com/ITqdvaU.png) 打勾會全部展開 ![](https://i.imgur.com/lPKxjan.png) 點魔法棒會顯示state名稱 ![](https://i.imgur.com/geLT3Ga.png)

    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