Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Console: VM

When executing a script directly in the console in Chrome, I saw this:

enter image description here

Does anyone know what's the meaning of VM117:2

What does VM stand for ?

like image 768
edi9999 Avatar asked Dec 04 '13 23:12

edi9999


People also ask

What is VM in Chrome console?

It is abbreviation of the phrase Virtual Machine. In the Chrome JavaScript engine (called V8) each script has its own script ID. Sometimes V8 has no information about the file name of a script, for example in the case of an eval .

How do I access the Chrome console?

Chrome. To open the developer console window on Chrome, use the keyboard shortcut Ctrl Shift J (on Windows) or Ctrl Option J (on Mac). Alternatively, you can use the Chrome menu in the browser window, select the option "More Tools," and then select "Developer Tools."

How do I open Chrome console in Linux?

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

How do I run a command in Chrome console?

1. Open the web page or site, on which, you want to run the JavaScript command. 3. Click on 'Console' or use the Ctrl+Shift+ J shortcut instead or you can bring the console to the front by right-clicking on the page and selecting 'Inspect element' , … so many ways to open the JavaScript Console in Chrome.


2 Answers

It is abbreviation of the phrase Virtual Machine. In the Chrome JavaScript engine (called V8) each script has its own script ID.

Sometimes V8 has no information about the file name of a script, for example in the case of an eval. So devtools uses the text "VM" concatenated with the script ID as a title for these scripts.

Some sites may fetch many pieces of JavaScript code via XHR and eval it. If a developer wants to see the actual script name for these scripts she can use sourceURL. DevTools parses and uses it for titles, mapping etc.

like image 59
loislo Avatar answered Oct 09 '22 09:10

loislo


Thanks to @MRB,

I revisited this problem, and found the solution today, thanks to https://stackoverflow.com/a/63221101/1818089

queueMicrotask (console.log.bind (console, "Look! No source file info..."));

It will group similar elements, so make sure you add a unique identifier to each log line to be able to see all data.

enter image description here

Demonstrated in the following example.

Instead of

data = ["Apple","Mango","Grapes"];
for(i=0;i<10;i++){
    queueMicrotask (console.log.bind (console, " info..."+i));
}

use

data = ["Apple","Mango","Grapes"];
for(i=0;i<data.length;i++){
    queueMicrotask (console.log.bind (console, " info..."+i));
}

A better way would be to make a console.print function that does so and call it instead of console.log as pointed out in https://stackoverflow.com/a/64444083/1818089

// console.print: console.log without filename/line number
console.print = function (...args) {
    queueMicrotask (console.log.bind (console, ...args));
}

Beware of the grouping problem mentioned above.

enter image description here

like image 2
computingfreak Avatar answered Oct 09 '22 10:10

computingfreak