Puppeteer with headless:true is extremely slow
See original GitHub issueThough this issues has been raised in https://github.com/GoogleChrome/puppeteer/issues/1550, but it was closed and the problem was not addressed.
My environment:
- Puppeteer Version: “puppeteer”: “^0.13.0”
- Windows Server 2008 R2 Enterprise with Service Pack 1 & command prompt
With the following minimal test script:
const puppeteer = require('puppeteer');
const headless = process.argv[2] === "headless";
(async () => {
const timeout = 30000
const browser = await puppeteer.launch({
headless: headless,
timeout,
});
const page = await browser.newPage();
const label = "Go to Bing " + (headless?"without": "with") + " head."
console.time(label)
await page.goto("https://www.bing.com/", { timeout })
const title = await page.title()
console.log("Title: " + title)
console.timeEnd(label);
await browser.close();
})();
To aid debugging, I turned on debugging and collected two logs: headless.log & head.log respectively.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:32 (5 by maintainers)
Top Results From Across the Web
How to speed up puppeteer? - Stack Overflow
It can really depends on the site you are visiting, but you are able to speed up the process of recognition of your...
Read more >Improving Puppeteer Performance - browserless docs
One of the things that stands out when using a headless browser (versus cURL or other simpler tools) is that it can be...
Read more >Now that i have puppeteer working, it is extremely slow
So i implemented a couple lines to see how long it takes to set cookies, it takes anywhere from 8-16 seconds JUST to...
Read more >Why is Playwright and Puppeteer so slow? Am I using it wrong?
Non-headless actually seems to be faster for whatever reason. ... For scrapping they are too slow, because they are fully rendering content ......
Read more >8 Tips for Faster Puppeteer Screenshots - Bannerbear
When optimizing Puppeteer, remember that there are only so many ways to speed ... browser = await puppeteer.launch({ headless: true, args: minimal_args }) ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey guys, so I’ve found a workaround for this. I found the answer in another thread unrelated to puppeteer but also has the problem with chromium being extremely slow in headless mode. I noticed that when I tried to debug chromium that network requests were the slow bit in terms of headless mode so I searched for that.
When launching the browser add these 2 arguments to the list and it seems (for me anyway) to resolve all issues with speed.
Link to thread if you’re interested: https://github.com/Codeception/CodeceptJS/issues/561 and props to oligee80 (who found the answer) for saving me about a week of work rolling back a bunch of product releases! 🎉
Try setting a valid UserAgent. This worked for me.