Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make JavaScript files show up in the list under "Scripts" in Google Chrome?

I have added 4 JavaScript files to my page:

<script src="scripts/jquery/jquery-1.6.2.min.js"></script>
<script src="scripts/jquery/jquery.mobile-1.0b2.min.js"></script>
<script src="scripts/config.js"></script>
<script src="scripts/test.js"></script>

Google Chrome lists the first two files under scripts but not the last two. If I add the folloing JavaScript to the test.js the alert happens:

alert('test');

How can I make chrome pick up the file to debug?

In the Developer Tools the last two scripts are not showing up. How can I make them show up?

like image 737
Dappy Avatar asked Aug 27 '11 19:08

Dappy


People also ask

How do I enable the JavaScript console in Chrome?

To open the developer console in Google Chrome, open the Chrome Menu in the upper-right-hand corner of the browser window and select More Tools > Developer Tools. You can also use Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux).

Where does Chrome store JS files?

On Windows they live at C:\Users\<user-name>\AppData\Local\Google\Chrome\User Data\Default\Code Cache\Js, while on macOS they're at ~/Library/Caches/Google/Chrome/Default/Cache/Js.

Can you view JavaScript in inspect element?

There's a powerful tool hiding in your browser: Inspect Element. Right-click on any webpage, click Inspect, and you'll see the innards of that site: its source code, the images and CSS that form its design, the fonts and icons it uses, the Javascript code that powers animations, and more.


3 Answers

Your scripts probably get completely collected (by GC) before debugger has a chance to see them. I guess there are no global functions in these scripts.

If I'm right, you can try to put something simple like "function A111() {}" and check that the scripts are there now.

like image 198
beefeather Avatar answered Oct 25 '22 20:10

beefeather


I would check the resources tab in dev tools and see if they are there under scripts.

also include type just to be safe

<script type="text/javascript" src="script.js"></script>

do you have a live example (link)?

like image 31
Joshua Wooward Avatar answered Oct 25 '22 22:10

Joshua Wooward


I had this problem and the reason was: there was a JavaScript syntax error in the script and so that script didn't load in.

If you do have a syntax error, simply go to the Console tab in Developer Tools and look for any red lines e.g. "Uncaught SyntaxError: Unexpected identifier". On the right hand side is a link to the filename and line number so Chrome will tell you EXACTLY where your problem is.

like image 1
Chris Walsh Avatar answered Oct 25 '22 21:10

Chris Walsh