Lines (JavaScript) is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Lines (JavaScript)
API ID: CountLineJavascriptLanguages: Web
Targets: Architectures, Files, Project
Number of all JavaScript lines.
Counts the lines inside an embedded <script> block (or a linked .js file), not including the <script>/</script> tag lines themselves, which count as HTML.
For example:
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
<!-- Greeting script: tracks visits and confirms with the user -->
<script>
// Number of times the page has greeted someone
var greetingCount = 0;
function greetUser(name) {
greetingCount++;
return "Hello, " + name + "!";
}
let message = greetUser("Ada");
console.log(message);
if (greetingCount > 0) {
confirm(message);
}
</script>
</head>
<body>
<h1>Welcome to the site</h1>
<p>Have a look around.</p>
</body>
</html>
Lines 8-21, the full body of the <script> block, are JavaScript, giving CountLineJavascript = 14. The <script> (7) and </script> (22) tag lines themselves count towards CountLineHtml instead.
See Lines (HTML) for the surrounding page, and Code Lines (JavaScript), Comment Lines (JavaScript), and Blank Lines (JavaScript) for the JavaScript breakdown. See Lines for the language-independent total across the whole file.
Targets By Language:- Web: Project, File
- This metric can be disabled from "Project Configuration/Metrics/Lines and Statements" with the "Show line count metrics" option.
- This metric can be enabled from "Project Configuration/Metrics/Lines and Statements" with the "Breakdown counts by web language" option.