I'm tired of re-typing the same commands into Chrome's developer console. Is it possible to load a script that I have saved on my local machine?
Asked
Active
Viewed 2.8k times
16
-
2This is precisely what the upcoming Snippets support is all about: http://stackoverflow.com/questions/10470711/chrome-developer-tools-what-is-snippets-support – Paul Irish May 17 '12 at 16:34
-
check out this similar question: http://stackoverflow.com/questions/5282228/include-javascript-file-in-chrome-console – Andy Jun 11 '12 at 23:27
2 Answers
17
If you're running developer tools on a file:// URL, you can do something like:
s = document.createElement('script');
s.src = 'file://path/to/script.js';
document.body.appendChild(s);
As a workaround you could also paste in your oft-repeated code snippet into the developer tools.

Roman Kagan
- 10,440
- 26
- 86
- 126

Boris Smus
- 8,220
- 2
- 36
- 33
-
`(function() { var s = document.createElement('script'); s.src = 'https://code.jquery.com/jquery-3.2.1.min.js'; document.body.appendChild(s); })();` – Christian Aug 29 '17 at 19:07
-
-
8
As @PaulIrish pointed out in the comments Chrome's Snippets
are their solution to this problem. This screenshot below shows were to find snippets within Chrome's developer tools as of this writing. To run a snippet right click on its entry in the snippet pane, pictured on the left, and select "Run":

Grant Humphries
- 2,696
- 2
- 23
- 24