Browser-rendering /screenshot API seems to be slow. Here are some numbers. I have a page that is
ready
ready
after ~150ms. I have a script that adds an indicator div to the dom, it finishes after ~350-450ms The script prints the timers to the dom, so when the screenshot runs I know when it was taken.
I'm using screenshot API with
waitForSelector
waitForSelector
that waits for the indicator div, with a timeout of 1000. There are no other
waitFor*
waitFor*
parameters.
Despite that, the API returns after 3.5-4.5 seconds consistently, and sometimes even more. I tested it both from a worker, and from postman. btw, a request from postman that took 3.47 seconds, had the header
X-Browser-Ms-Used 1393.57373046875
X-Browser-Ms-Used 1393.57373046875
In the image you can see that the screenshot was taken 550ms after the script started to run (it's not from the moment that the page started to load, but it's really negligible). At 514ms the indicator div was ready. The document was already ready when the script started to run, so it shows .