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?
-
2This is precisely what the upcoming Snippets support is all about: stackoverflow.com/questions/10470711/…– Paul IrishMay 17, 2012 at 16:34
-
check out this similar question: stackoverflow.com/questions/5282228/…– AndyJun 11, 2012 at 23:27
2 Answers
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.
-
(function() { var s = document.createElement('script'); s.src = 'https://code.jquery.com/jquery-3.2.1.min.js'; document.body.appendChild(s); })();
Aug 29, 2017 at 19:07 -
This now returns the error "Not allowed to load local resource" Sep 16, 2017 at 14:08
-
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":