Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Javascript in Playwright

Tags:

playwright

Is it possible to define a browser with Javascript disabled to simulate how a crawler would view a page? There should be an option that can be passed.

like image 673
Dietrich Avatar asked Dec 14 '25 05:12

Dietrich


1 Answers

You can pass javaScriptEnabled in the BrowserContext options:

const playwright = require("playwright");

(async () => {
  const browser = await playwright.chromium.launch();
  const context = await browser.newContext({
    javaScriptEnabled: false
  });
  const page = await context.newPage();
  // ...
  await browser.close();
})();
like image 60
Max Schmitt Avatar answered Dec 16 '25 22:12

Max Schmitt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!