Chrome, Edge, Opera
Sources > In the left sidebar, open Snippets > Click "+ New snippet". This will open an empty file in the main view.
Enter the snippet and press
Cmd+Enter
to run the code.
Firefox
Open Console (
Cmd+Opt+K
orCtrl+Shift+K
) > Switch to multi-editor mode (Cmd+B
orCtrl+B
).This will open the editor next to the Console, where you can enter the snippet and click "Run" to execute.
Safari
In Sources > Click the "+" button to Create Resource > "Console Snippet...". Input the name of the snippet and enter the script.
Click the Play button next to the snippet name to execute the code in Console.