omega
omega

Reputation: 43843

How to name an eval script file in a browser debugger tools?

In a javascript file, I have a jquery function that loads a javascript file using getScript. The problem is when I want to debug the downloaded script, it is not easy to find it in debugger tools. It looks like this:

enter image description here

Where it says eval code, thats the downloaded script. Is there a way I can put a name on that? Like for example in the script thats being downloaded, I want something like

namespace("control.js");

Then in the debugger tools, instead of 'eval code' it will say 'control.js'.

Does anyone know a way for this?

Thanks

Upvotes: 0

Views: 680

Answers (2)

thegunmaster
thegunmaster

Reputation: 295

A bit of a late response, but this might be useful for other people still;

//# sourceURL=url

The above can be added to the end of an eval string, to indicate its source. I am not sure if it would show up properly in those debugger tools. But it does at least show up properly when it is logging data in chrome.

source: https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl

Upvotes: 2

guest271314
guest271314

Reputation: 1

At chromium / chrome , should be able to open console -> select Sources tab, select resource from left panel -> copy source of resource -> at left panel select Snippets -> right click in Snippets panel , select New -> name snippet when *Script snippet #n highlighted in left panel -> paste source of selected resource into middle panel -> select all pasted source of resouce -> right click while source highlighted -> select Add to Watch -> at right panel selected snippet should be listed at Watch Expressions

Upvotes: 0

Related Questions