DevTools Tips: Snippets and live expressions
Stay organized with collections
Save and categorize content based on your preferences.
Use Snippets in DevTools to run code you frequently use and live expression to watch JavaScript values in real time.
Watch the video to learn how to:
Create a snippet or open the Snippets pane:
Run your new snippet:
- With the Command / Control + Enter shortcut in Sources
- From the Command Menu using
!
.
Pass values to your snippet:
- Pause it with a breakpoint.
- Set values in the Sources > Scope pane.
- Resume execution.
Execute snippets from the Console: load them as global functions and run once.
Use Console Utilities API in your snippets.
Use Console > Live Expressions:
- To execute a piece of code you want to run repeatedly, for example, during a debugging session.
- Watch how the values change during execution in real time.
To learn more, see:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-08-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-08-31 UTC."],[],[]]