Skip to content

Commit aada9b1

Browse files
committed
localhost in Quick source
1 parent 9a266d4 commit aada9b1

8 files changed

Lines changed: 172 additions & 45 deletions

File tree

11.8 KB
Loading
77.6 KB
Loading
-10.1 KB
Loading
333 Bytes
Loading
-13.1 KB
Loading

microsoft-edge/devtools-guide-chromium/quick-source/quick-source-tool.md

Lines changed: 111 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,14 @@ ms.date: 03/07/2025
1010
---
1111
# Display or edit source files using the Quick source tool
1212
<!-- https://developer.chrome.com/docs/devtools/quick-source -->
13-
<!-- first give the always-available GUI way, then keyboard shortcuts
14-
don't doc the empty tool UI, which is transient and is designed for the Sources tool -->
13+
<!-- give the always-available GUI way, don't doc the empty tool UI -->
1514

1615
Use the **Quick source** tool to display or edit source files at the same time as displaying a tool other than the **Sources** tool. The **Quick source** tool always displays the same files that are open in the **Sources** tool.
1716

18-
![The Quick source tool](./quick-source-tool-images/quick-source-tool.png)
17+
![The Quick source tool](./quick-source-tool-images/quick-source-tool.png)<!-- todo: localhost -->
1918

2019
The main place to view source files in the DevTools is within the **Sources** tool. But sometimes you need to access other tools, such as **Elements** or **Console**, while viewing or editing your source files. Use the **Quick source** tool, which by default opens in the **Quick View** panel at the bottom of DevTools.
2120

22-
<!-- incoming overflow: removed from Workspace tut so that can focus only on teaching Workspace, not also Quick source.
23-
You can edit and save the JavaScript (or HTML or CSS) file in the **Sources** tool's editor, or in the **Quick source** tool in the **Quick View** panel at the bottom of DevTools.
24-
25-
The main place to use the code editor of DevTools is the **Sources** tool. But sometimes you need to access other tools, such as the **Elements** tool or the **Console**, while editing files. The **Quick source** tool gives you just the editor from the **Sources** tool (without the **Navigator** or **Debugger** pane), while any tool is open in the upper part of DevTools.
26-
27-
We'll walk through a couple ways to open the **Quick source** tool and open a file in the **Quick source** tool:
28-
* The regular, GUI way.
29-
* The **Command Menu** shortcut way.
30-
-->
31-
3221

3322
<!-- ------------------------------ -->
3423
#### Use the Quick source tool in conjunction with the Sources tool
@@ -43,11 +32,11 @@ If you open or close a file in one tool, the file is opened or closed in the oth
4332
<!-- ====================================================================== -->
4433
## Open a file in the Quick source tool
4534

46-
<!-- todo: run & show localhost in addr bar instead of github.io? -->
35+
<!-- todo: run & show localhost in addr bar instead of github.io -->
4736

4837
To view source files while using a tool than the **Sources** tool in the **Activity Bar**, use the **Quick source** tool, as follows:
4938

50-
1. Open a webpage; for example, open [Demo To Do](https://microsoftedge.github.io/Demos/demo-to-do/) in a new window or page.
39+
1. Open a webpage; for example, open [Demo To Do](https://microsoftedge.github.io/Demos/demo-to-do/) in a new window or page.<!-- todo: localhost -->
5140

5241
1. Right-click the webpage and then select **Inspect**.
5342

@@ -69,7 +58,7 @@ To view source files while using a tool than the **Sources** tool in the **Activ
6958

7059
The **Quick source** tool expands in **Quick View** at the bottom of DevTools, and displays the same files that are open in the **Sources** tool:
7160

72-
![A file displayed in the Quick source tool](./quick-source-tool-images/file-displayed-in-quick-source.png)
61+
![A file displayed in the Quick source tool](./quick-source-tool-images/file-displayed-in-quick-source.png)<!-- todo: simpler display -->
7362

7463
You can now view or edit the file in the **Quick source** tool, at the same time as displaying a different tool in the main part of DevTools.
7564

@@ -91,13 +80,17 @@ To edit source files in the **Quick source** tool:
9180
These steps are detailed below.
9281

9382

94-
<!-- ------------------------------ -->
95-
#### Have local source files, such as a cloned repo
83+
<!-- ====================================================================== -->
84+
## Have local source files, such as a cloned repo
9685

9786
To use the **Quick source** tool to save changes locally, you must have local source files that match the web server files. Make sure there are source files on your local drive, that match the transient files that are returned by the web server.
9887

9988
For example, if not done already, clone the **MicrosoftEdge / Demos** repo to your local drive, as follows:
10089

90+
1. If not done already, [Download git](https://git-scm.com/downloads) and install it.
91+
92+
1. If not done already, install an up-to-date version of Node.js and npm from [Node.js](https://nodejs.org).
93+
10194
1. Go to [MicrosoftEdge / Demos](https://github.com/MicrosoftEdge/Demos) in a new window or tab.
10295

10396
1. Click the **Code** drop-down button.
@@ -132,10 +125,59 @@ Now you have a local folder of source files (such as `/demo-to-do/`) that match
132125
Continue with the next section.
133126

134127

135-
<!-- ------------------------------ -->
136-
#### Select a local folder of source files as the Workspace
128+
<!-- ====================================================================== -->
129+
## Start a localhost server
130+
131+
1. Go to a command prompt, such as the git bash shell, or the Terminal pane in Microsoft Visual Studio Code.
132+
133+
1. Go to the cloned `/demo-to-do/` directory, such as `C:\Users\localAccount\GitHub\Demos\demo-to-do\`.
134+
135+
If you use the git bash shell, it's a UNIX shell, so even on Windows, you need to wrap a directory path that has backslashes in quotes, or else use forward slashes rather than backslashes.
136+
137+
1. Run one of the following commands, to start the web server:
138+
139+
```bash
140+
# Node.js option
141+
cd ~/GitHub/demos/demo-to-do
142+
npx http-server # Node.js
143+
```
144+
145+
For more information and options, see [Start the server (npx http-server)](../../visual-studio-code/microsoft-edge-devtools-extension/install.md#start-the-server-npx-http-server) in _Installing the DevTools extension for Visual Studio Code_.
146+
147+
``` bash
148+
# Python 2 option
149+
cd ~/GitHub/demos/demo-to-do
150+
python -m SimpleHTTPServer # Python 2
151+
```
152+
153+
``` bash
154+
# Python 3 option
155+
cd ~/GitHub/demos/demo-to-do
156+
python -m http.server # Python 3
157+
```
158+
159+
1. Open a tab in Microsoft Edge, and go to the locally hosted version of the site. You should be able to access it by using `localhost:8080`:
160+
161+
![The DevTools TODO app demo](./quick-source-tool-images/demo-to-do.png)
162+
163+
Another common equivalent URL is `http://0.0.0.0:8080`. The default port number for the Python server option is `8000`. The exact [port number](https://wikipedia.org/wiki/Port_(computer_networking)#Use_in_URLs) might be different.
164+
165+
The **DevTools Workspaces Demo** webpage opens.
166+
167+
See also:
168+
* [Running a simple local HTTP server](https://developer.mozilla.org/docs/Learn/Common_questions/set_up_a_local_testing_server#running_a_simple_local_http_server) in _How do you set up a local testing server?_ at MDN - shows Python.
169+
<!--
170+
* [Set up a localhost server](../../visual-studio-code/microsoft-edge-devtools-extension/install.md#step-6-set-up-a-localhost-server) in _Installing the DevTools extension for Visual Studio Code_. How to run a local HTTP web server by using Node.js. -->
171+
172+
Continue with the next section.
137173

138-
<!-- todo: start localhost server -->
174+
175+
<!-- ====================================================================== -->
176+
## Select a local folder of source files as the Workspace
177+
178+
1. Continuing from above, right-click the demo webpage and then select **Inspect**.
179+
180+
DevTools opens.
139181

140182
1. In the **Activity Bar** at the top of DevTools, select the **Sources** (![The Sources tool icon](./quick-source-tool-images/sources-icon.png)) tool, select the **Workspace** tab (grouped with the **Page** tab), and then in the **Workspace** tab, click the **Add folder** button.
141183

@@ -147,38 +189,65 @@ Continue with the next section.
147189

148190
1. Click the **Allow** button.
149191

150-
The **Sources** tool is opened.
192+
The tree of `demo-to-do` files appears in the **Workspace** tab of the **Sources** tool. The HTML, JS, and CSS files have a green "mapped" dot.
151193

152-
1. In the **Sources** tool, in the **Workspace** tab, expand the tree, and then click one or more files, such as `to-do.js`.
194+
1. In the **Workspace** tab, expand the file tree, and then click one or more files, such as `to-do.js`.
153195

154196
The file opens in the **Sources** tool:
155197

156-
![The Sources tool with a file selected](./quick-source-tool-images/sources-tool-with-file-selected.png)<!-- todo: localhost in addr bar -->
198+
![The Sources tool with a file selected](./quick-source-tool-images/sources-tool-with-file-selected.png)
157199

158200
1. In the **Activity Bar** at the top of DevTools, select a tool other than the **Sources** tool, such as the **Elements** tool.
159201

160202
The **Quick source** tool expands in **Quick View** at the bottom of DevTools, and has a tab for each open file:
161203

162-
![A file displayed in the Quick source tool.](./quick-source-tool-images/file-displayed-in-quick-source-2.png)<!-- copied from above then appended -2 --><!-- todo: localhost in addr bar -->
204+
![A file displayed in the Quick source tool.](./quick-source-tool-images/file-displayed-in-quick-source-2.png)<!-- todo: localhost in addr bar -->
205+
206+
1. If there's no longer a green "mapped" dot on the HTML, JS, or CSS file, long-click or right-click the **Refresh** button in Microsoft Edge, and then select **Hard refresh** (**Ctrl+Shift+R**).
163207

164208
Continue with the next section.
165209

166210

167-
<!-- ------------------------------ -->
168-
#### Open the Quick source tool
211+
<!-- ====================================================================== -->
212+
## Open the Quick source tool and edit a file
213+
214+
Suppose you want to continue viewing the **Elements** tool, but you want to simultaneously view and edit the source files that were opened via the **Sources** tool.
169215

170-
1. In the **Activity Bar**, select a tool other than the **Sources** tool, such as the **Elements** tool.
216+
1. Continuing from above, in the **Activity Bar**, select a tool other than the **Sources** tool, such as the **Elements** tool.
171217

172218
1. If the **Quick View** toolbar isn't shown at the bottom of DevTools, press **Esc**.
173219

174220
1. In the **Quick View** toolbar at the bottom of DevTools, click the **More tools** button, and then select **Quick source**.
175221

176222
The **Quick source** tool opens in **Quick View** at the bottom of DevTools:
177223

178-
![The Quick source tool, containing a Select folder link](./quick-source-tool-images/quick-source-select-folder.png)
224+
![The Quick source tool, containing a Select folder link](./quick-source-tool-images/quick-source-select-folder.png)<!--todo:localhost-->
225+
226+
`todo.js` is displayed, because that file is open in the **Sources** tool.
227+
228+
1. In the demo To Do webpage, delete any tasks.
229+
230+
1. Click the **Quick source** panel, and then press **Ctrl+F**.
231+
232+
In the **Quick source** tool, the **Find** UI appears.
233+
234+
1. Enter **no tasks**, and then press **Enter**.
179235

180-
The **Quick source** tool might show instructions including an **Select folder** link, or it might display a file. Instead of relying on that transient link, the steps further below show how to use the **Workspace** tab in the **Sources** tool, to select a local folder of source files.
236+
1. In the line of code, change `no tasks` to `0 tasks`.
181237

238+
An asterisk appears on the file name tab.
239+
240+
1. Press **Ctrl+S**.
241+
242+
The asterisk is removed from the file name tab.
243+
244+
1. Refresh the demo webpage (**Ctrl+R**).
245+
246+
1. If the rendered webpage doesn't change from "No" to "0", and there's no longer a green "mapped" dot on the JS file name tab, long-click or right-click the **Refresh** button in Microsoft Edge, and then select **Hard refresh** (**Ctrl+Shift+R**).
247+
248+
The rendered webpage changes from "No" to "0", and there's a green "mapped" dot on the JS file name tab.
249+
250+
![An edited .js file in the Quick source tool, with refreshed demo webpage](./quick-source-tool-images/edited-js-file.png)
182251

183252
Now, when you edit the folder's files in DevTools, the edits are not only made to the transient file that's returned by the server, but are also saved to the source files on your local drive. You can edit the file from within the **Quick source** tool at the same time as displaying another tool (or from within the **Sources** tool).
184253

@@ -220,6 +289,18 @@ To open a file by using the **Open File** prompt of the **Command Menu**, do any
220289
To display the **Open file** link in the instructions in the panel, you might need to scroll down, or drag the **Quick View** divider up to make the **Quick View** panel taller.
221290

222291

292+
<!-- ====================================================================== -->
293+
## Keyboard shortcuts in the Quick source tool
294+
295+
The **Quick source** tool has a streamlined UI. Use these keyboard shortcuts.
296+
297+
* **Ctrl+F** - Find.
298+
299+
* **Ctrl+S** - Save. If there's no longer a green "mapped" dot on the HTML, JS, or CSS file name, long-click or right-click the **Refresh** button in Microsoft Edge, and then select **Hard refresh** (**Ctrl+Shift+R**).
300+
301+
* **Ctrl+P** - Open a file by using the **Command Menu**. Same as going to the **Sources** tool and then clicking a file in the **Workspace** tab.
302+
303+
223304
<!-- ====================================================================== -->
224305
## Close a file
225306

microsoft-edge/devtools-guide-chromium/sources/index.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: msedgedevrel
66
ms.topic: conceptual
77
ms.service: microsoft-edge
88
ms.subservice: devtools
9-
ms.date: 07/21/2023
9+
ms.date: 04/18/2025
1010
---
1111
<!-- Copyright Kayce Basques
1212
@@ -25,19 +25,39 @@ ms.date: 07/21/2023
2525

2626
Use the **Sources** tool to view, modify, and debug front-end JavaScript code, and to inspect the resources that make up the current webpage.
2727

28-
2928
**Detailed contents:**
3029

31-
todo: update
32-
33-
<!-- omit h4s
34-
* [Icons in the Page tab](#icons-in-the-page-tab)
35-
* [Group files by folder or as a flat list](#group-files-by-folder-or-as-a-flat-list)
36-
37-
* [Save and Undo](#save-and-undo)
38-
* [Find and Replace](#find-and-replace)
39-
* [Showing the changes you made](#showing-the-changes-you-made)
40-
* [Changes inside a function take effect](#changes-inside-a-function-take-effect) -->
30+
* [The Navigator, Editor, and Debugger panes](#the-navigator-editor-and-debugger-panes)
31+
* [Using the Navigator pane to select files](#using-the-navigator-pane-to-select-files)
32+
* [Using the Page tab to explore resources that construct the current webpage](#using-the-page-tab-to-explore-resources-that-construct-the-current-webpage)
33+
* [Icons in the Page tab](#icons-in-the-page-tab)
34+
* [Group files by folder or as a flat list](#group-files-by-folder-or-as-a-flat-list)
35+
* [Add a local folder to the workspace, to use DevTools to edit files and save changes to disk](#add-a-local-folder-to-the-workspace-to-use-devtools-to-edit-files-and-save-changes-to-disk)
36+
* [Using the Overrides tab to override server files with local files](#using-the-overrides-tab-to-override-server-files-with-local-files)
37+
* [Using the Content scripts tab for Microsoft Edge extensions](#using-the-content-scripts-tab-for-microsoft-edge-extensions)
38+
* [Using the Snippets tab to run JavaScript code snippets on any webpage](#using-the-snippets-tab-to-run-javascript-code-snippets-on-any-webpage)
39+
* [Using the Command Menu to open files](#using-the-command-menu-to-open-files)
40+
* [Using the Editor pane to view or edit files](#using-the-editor-pane-to-view-or-edit-files)
41+
* [Editing a JavaScript file](#editing-a-javascript-file)
42+
* [Save and Undo](#save-and-undo)
43+
* [Find and Replace](#find-and-replace)
44+
* [Showing the changes you made](#showing-the-changes-you-made)
45+
* [Changes inside a function take effect](#changes-inside-a-function-take-effect)
46+
* [Reformatting a minified JavaScript file with pretty-print](#reformatting-a-minified-javascript-file-with-pretty-print)
47+
* [Mapping minified code to your source code to show readable code](#mapping-minified-code-to-your-source-code-to-show-readable-code)
48+
* [Transformations from source code to compiled front-end code](#transformations-from-source-code-to-compiled-front-end-code)
49+
* [Editing CSS](#editing-css)
50+
* [Editing CSS by using the Styles tab in the Elements tool, when using the Workspace tab of the Sources tool](#editing-css-by-using-the-styles-tab-in-the-elements-tool-when-using-the-workspace-tab-of-the-sources-tool)
51+
* [The Page tab or Workspace tab in the Sources tool](#the-page-tab-or-workspace-tab-in-the-sources-tool)
52+
* [Editing an HTML file](#editing-an-html-file)
53+
* [Going to a line number or function](#going-to-a-line-number-or-function)
54+
* [Quick source tool, to display source files when using a different tool](#quick-source-tool-to-display-source-files-when-using-a-different-tool)
55+
* [Using the Debugger pane to debug JavaScript code](#using-the-debugger-pane-to-debug-javascript-code)
56+
* [The basic approach to using a debugger](#the-basic-approach-to-using-a-debugger)
57+
* [Advantages of the debugger's Watch and Scope over console.log](#advantages-of-the-debuggers-watch-and-scope-over-console.log)
58+
* [Debug from Visual Studio Code directly](#debug-from-visual-studio-code-directly)
59+
* [Articles about debugging](#articles-about-debugging)
60+
* [See also](#see-also)
4161

4262

4363
<!-- ====================================================================== -->

0 commit comments

Comments
 (0)