How to Disable JavaScript in Puppeteer
Disable JavaScript for a Puppeteer page before navigation with setJavaScriptEnabled(false). Learn how timing, page scope, verification, and common errors affect the result.
To disable JavaScript in Puppeteer, call await page.setJavaScriptEnabled(false) before navigating to the page. The setting takes full effect on the next navigation; it does not undo scripts that have already run.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setJavaScriptEnabled(false);
await page.goto('https://example.com');
console.log(await page.isJavaScriptEnabled()); // true or false
} finally {
await browser.close();
}
page.isJavaScriptEnabled() reports the page’s configured setting. It does not confirm that the site renders correctly without JavaScript. See the official Puppeteer setJavaScriptEnabled() reference and isJavaScriptEnabled() reference.
1. Disable JavaScript before navigation
setJavaScriptEnabled(enabled) is a method on Puppeteer’s Page class. It takes a boolean and returns a promise. Pass false before the navigation whose page scripts you want disabled:
await page.setJavaScriptEnabled(false);
await page.goto('https://example.com');
The order matters. Changing the setting does not stop scripts that have already run in the current document. The change takes effect on the next navigation, so if you have already loaded the target, navigate again after changing the setting.
2. Complete runnable example
This example launches Puppeteer’s default browser, disables JavaScript for a new page, loads a URL, checks the configured state, and closes the browser even if navigation fails.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setJavaScriptEnabled(false);
await page.goto('https://example.com', {
waitUntil: 'domcontentloaded',
timeout: 30_000,
});
const enabled = await page.isJavaScriptEnabled();
console.log(`JavaScript enabled: ${enabled}`);
console.log((await page.title()) || '(no document title)');
} finally {
await browser.close();
}
The example uses domcontentloaded because a site may keep network requests open or depend on JavaScript for its later rendering. Choose a wait condition based on what you need to inspect. Disabling JavaScript does not mean every site will become usable or fully rendered.
3. Scope: configure each page you control
The setting belongs to a Puppeteer Page. Set it on every page whose JavaScript behavior matters; do not assume changing one page configures all other pages. For example, explicitly configure both pages when opening separate pages:
const firstPage = await browser.newPage();
await firstPage.setJavaScriptEnabled(false);
const secondPage = await browser.newPage();
await secondPage.setJavaScriptEnabled(false);
await firstPage.goto('https://example.com');
await secondPage.goto('https://example.org');
Popups belong to their parent page’s browser context, but the cited API references do not establish that changing a page’s setting automatically changes another page’s setting. For predictable automation, set and verify the option on each page you use.
4. Verify the configured setting
Use await page.isJavaScriptEnabled() to read the page’s configured state. It resolves to a boolean:
await page.setJavaScriptEnabled(false);
console.log(await page.isJavaScriptEnabled()); // false
Call it after setting the option if you want to check your configuration. This check is not a test of page functionality: a false result does not tell you whether content is present, whether scripts ran before the setting took effect, or whether the site needs JavaScript to render.
5. What changes when JavaScript is disabled
The browser will not execute page JavaScript after the setting takes effect. That can be useful when you want to inspect a page’s non-scripted response or see how it behaves without client-side code. It can also leave a page incomplete:
- Content inserted by client-side rendering may not appear.
- Navigation, menus, forms, and other interactions implemented in scripts may stop working.
- Some pages may show a loading state or an empty application shell.
- Server-rendered HTML and static assets may still be available, depending on the site.
Disabling scripts is a browser setting, not a guarantee that the page will be simpler, faster, or fully accessible. Inspect the actual response and rendered output for your use case.
6. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The page’s JavaScript still appears to run. | The page was navigated before JavaScript was disabled, or scripts already ran in the document. | Set the option before navigation, then navigate to the page. The change takes effect on the next navigation. |
isJavaScriptEnabled() returns true. |
The page setting is still enabled, or the option was applied to a different page. | Call await page.setJavaScriptEnabled(false) on the page you are checking, then verify that same page. |
| The page is blank or missing content. | The site may build that content with JavaScript. | That output may be expected with scripts disabled. If you need the rendered application, leave JavaScript enabled or inspect the server response separately. |
| Navigation times out while waiting for the page to finish loading. | The selected wait condition may not complete for this page, even with JavaScript disabled. | Choose a wait condition suited to the inspection, such as domcontentloaded, and set a deliberate timeout. Do not treat a timeout as proof that JavaScript ran. |
| Behavior differs between a bundled browser and a connected browser. | Puppeteer support depends on the Puppeteer release and its supported browser versions. | Check the official Puppeteer supported browsers matrix for the installed version and browser you use. |
7. Performance, reliability, and cost
This setting changes JavaScript execution behavior; it does not itself set a timeout, choose a navigation wait condition, or guarantee a performance improvement. Pages that rely on scripts may do less work but also return less useful output. Measure the behavior that matters to your task rather than assuming disabling JavaScript will make every capture faster.
For reliable automation, set the option before the relevant navigation, configure each controlled page explicitly, and handle navigation failures with cleanup such as the finally block in the example. Keep the Puppeteer and browser versions compatible according to the supported browsers table. There is no separate cost for this page setting documented in the referenced API; browser runtime and infrastructure costs depend on how you run your automation.
8. Or skip the browser setup
If your goal is a website screenshot rather than controlling Puppeteer itself, ScreenshotNeo is a website screenshot API and MCP server. Send one GET request with a URL to get an image or PDF. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
- Cookie banners, newsletter popups, and chat widgets are removed before the shot; each step can be turned off.
- Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. The response includes
X-Page-VerdictandX-Billedheaders. - An MCP server lets AI agents use
take_screenshot,get_page_info, andcapture_pdf. - 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000. Every feature is on every plan.
Sign up for ScreenshotNeo and get 1,000 screenshots a month free, with no card required.
9. FAQ
Does disabling JavaScript block it for the whole browser?
The documented methods are on Puppeteer’s Page class. Configure each page you control instead of assuming one page’s setting covers the whole browser.
Can I disable JavaScript after a page has loaded?
You can change the setting, but it does not undo scripts that have already run. It takes full effect on the next navigation.
Does a false setting prove that the site works without JavaScript?
No. It reports the configured state. Check the page output separately to determine what the site provides without scripts.
Does this work with every browser Puppeteer can connect to?
Check compatibility against the supported browser mapping for your installed Puppeteer version. Browser support changes with releases.


