¿Cómo hacer que los archivos JavaScript aparezcan en la lista de "Scripts" en 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?

preguntado el 27 de agosto de 11 a las 19:08

¿Hay una pregunta lurking in there? ;-) And: You're saying in the dev tools, the last two scripts aren't showing up in the drop-down list of scripts? -

Are the two scripts doing anything? My Chrome Dev picks up my scripts, which are all used within a function that runs on the body's onload. Maybe Chrome is ignoring them because they haven't come into play? -

They should show up. However if they don't, you should consider reporting the bug or updating Google Chrome. -

Are you sure they are actually coming down to the browser? Check the network tab... -

I've seen this before but haven't had luck figuring out a pattern to when it doesn't show up. -

3 Respuestas

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.

Respondido 12 Jul 12, 19:07

No creo que el archivos reales would be garbage collected while the developer tools are open. - lanzz

Ianzz, V8 holds reference to a script object only via function objects. If there are no function or all of them collected, the script object will be collected as well and you won't be able to work with it from debugger. - pluma de abeja

Es demostrablemente not true. Demo includes test.js, que define un locales variable y una locales function, thus no references to anything in test.js remain outside of it; still, it is displayed in the scripts pane of the devtools just fine. - lanzz

Ianzz, it doesn't show up for me. I just tried it. Note that GC does not guarantee to collect something in most cases. - pluma de abeja

I find it very counter-productive to GC the actual archivos from the debugger; these scripts might have no existing references at all, but still might do useful work during their execution (e.g. DOM manipulations), so it makes completely no sense to make debugging them hard or impossible by just tossing away them as garbage. - lanzz

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)?

Respondido el 01 de diciembre de 11 a las 08:12

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.

Respondido el 20 de junio de 12 a las 16:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.