How to stop all JS scripts in Puppeteer

If you would like to disable JavaScript after the page has loaded, you can use debugger:

await page.evaluate(() => {
  debugger;
});

I was able to take screenshots after using the debugger.

Alternatively, you can replace each original node with its clone to remove the events attached to each element:

await page.evaluate(() => {
  document.querySelectorAll('*').forEach(element => {
    element.parentNode.replaceChild(element.cloneNode(true), element);
  });
});

You can also use removeEventListener() in a loop similar to the one above to remove specific events attached to a node.

Otherwise, if you can disable JavaScript before the page has loaded, you can use page.setJavaScriptEnabled() before navigating to the page:

await page.setJavaScriptEnabled(false);

const page = await browser.newPage()
page.setJavaScriptEnabled(false)