Usage of external scripts doesn't block HTML parsing
Author: pmdartusCreated Nov 1, 2018Updated Sep 17, 2026
Labelsbugparsing
Basic info:
- Node.js version: v8.11.4
- jsdom version: v13.0.0
Minimal reproduction case
var { JSDOM } = require("jsdom");
new JSDOM(`
<!DOCTYPE html>
<meta charset=utf-8>
<script>
console.log("sync 0:", document.querySelectorAll('p').length);
</script>
<!-- Some external script -->
<script src="https://unpkg.com/[email protected]/dist/jquery.js"></script>
<p>First</p>
<script>
console.log("sync 1:", document.querySelectorAll('p').length);
</script>
<p>Second</p>
<script>
console.log("sync 2:", document.querySelectorAll('p').length);
</script>
`, {
resources: "usable",
runScripts: "dangerously"
});The usage of external script doesn't block jsdom from parsing the rest of the page.
Actual output:
sync 0: 0
sync 1: 2
sync 2: 2Expected output:
sync 0: 0
sync 1: 1
sync 2: 2How does similar code behave in browsers?
Source: jsdom/jsdom