Why use PhantomJS to use the window.setTimeout page

I am currently using PhantomJS for some doc reports and in some examples I have found this.

window.setTimeout(function () {
    page.render(output);
    console.log(output);
    phantom.exit();
}, 200);

I wonder why using window.setTimeout ?? Does it affect web rendering?

Thanks ... Nick.

+4
source share
1 answer

The page.open callback is only called when the page loads. This does not mean that everything has been uploaded to your page, and js has been fully executed.

In addition, js on a web page may not execute immediately, especially if the site uses MVC client frameworks such as AngularJS or Ember.js: there are a lot of things after the page load event.

setTimeout , , .

200 , .

- waitfor.js: , , , visisble.

+6

Source: https://habr.com/ru/post/1528859/


All Articles