Skip to content

naruaway-sandbox/wait-for-selector-perf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Puppeteer has much faster waitForSelector than Playwright

  • Note that this repro just compares waitForSelector performance. This alone does NOT mean "Puppeteer is faster in general"
  • GitHub issue in Playwright: microsoft/playwright#24578

Since Puppeteer is internally using polling: 'mutation' option in waitForFunction for waitForSelector, it will use MutationObserver to efficiently react to newly appeared DOM node.

On the other hand, Playwright removed polling: 'mutation' completely in this PR and its waitForSelector is purely relying on repeated retries on the hardcoded intervals here.

This repro has minimal demo to reproduce the performance difference caused by this implementation difference. Please check out ./main.js to see what is benchmarked first.

How to run the benchmark

npm ci
npm run puppeteer
npm run playwright

The result in my environment

I ran the above on my MacBook Air (M2) and the result was the following:

puppeteer: It took 10ms to react to the appearance of <a> element
playwright: It took 321ms to react to the appearance of <a> element

So Puppeteer has more than 20x faster waitForSelector compared with the one from Playwright.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published