How to make puppeteer headless mode as fast as possible? - puppeteer

I just wanted to know, what the common ways are, to make Puppeteer in headless mode even faster.
In other words, is it possible to reduce the loading times of websites in puppeteer?

Related

Monitoring headless Chrome

I'm using Chrome in headless mode via CDP (Chrome devtools protocol) to do HTML to PDF conversions. Works well but I do not trust Chrome to run forever and want to build a guardian service to monitor its responsiveness and if necessary kill the process and relaunch it.
What would be a good indicator of health? What I'm looking for is a low overhead test I can perform at fairly frequent intervals so that the restart latency is minimised.
I could try to perform some kind of CDP command if anyone has a suggestion and a reliable way to determine success.
I can't think of anything else, that's why I've thrown it open for suggestions.
My best suggestion for this case is to use the Target domain. Listening to some of the events that are fired from the target domain will give you some information regarding the state of your browser, such as TargetCrashed.
On top of that, you could use basic domains like Runtime (provides the evaluate method), SystemInfo or Browser to send the browser requests in order to check its health.

Speed of chrome.storage.sync.get vs get from chrome.storage.local

I'm developing a Chrome extension whose functionality relies on options, so I'm calling the main function is called as a callback after fetching options from Chrome storage.
In testing on my machine, I've had faster results from using chrome.storage.sync.get, rather than chrome.storage.local.get, but it's still slowing up the page load quite a bit. I wondered if that might be just my machine, and typically local.get would be faster, or if there's a way to cache these settings to be more easily accessible.
Thanks for the help! :)

Why Google Chrome run multiple processes when there is single tab opened?

It is logical to run multiple processes when multiple tabs are there but in my Google Chrome i found multiple processes under single tab only. I thought it was some thread stuck so i restarted my PC and opened Google Chrome only and found same behavior. I am using Windows 7.
Chrome has plugins, web apps, rendering engines and others as separate processes from the browser itself.
That is done so that if one of those processes fails, it won't affect the whole browser, or even the whole tab, because those are separate processes too.
For example, Firefox doesn't have that, instead it detects the script in the page that should be causing the problem and shows you a dialog for if you want to stop it.
In summary:
Chrome treats these as different processes:
The browser
The browser (yes, again. Chrome by itself it's already 2 processes)
Each tab
Each extension (at least one per extension)
Each web app
Each plugin
Each whatever, everybody is a process, yay!
And that helps things can run in parallel and that that stuff doesn't end up crashing the whole browser.
Less crashes or at least when a process crash not all the browser crash, increase security, to make things run in parallel
Google Chrome takes advantage of these properties and puts web apps and plug-ins in separate processes from the browser itself. This means that a rendering engine crash in one web app won’t affect the browser or other web apps. It means the OS can run web apps in parallel to increase their responsiveness, and it means the browser itself won’t lock up if a particular web app or plug-in stops responding. It also means we can run the rendering engine processes in a restrictive sandbox that helps limit the damage if an exploit does occur.In this world, browsers that put everything in one process face real challenges for robustness, responsiveness, and security. If one web app causes a crash in the rendering engine, it will take the rest of the browser with it, including any other web apps that are open. Web apps often have to compete with each other for CPU time on a single thread, sometimes causing the entire browser to become unresponsive. Security is also a concern, because a web page that exploits a vulnerability in the rendering engine can often take over your entire computer.
https://www.howtogeek.com/124218/why-does-chrome-have-so-many-open-processes/
On top of this, the parts of the browser that render HTML, JavaScript, and CSS have become extraordinarily complex over time. These rendering engines frequently have bugs as they continue to evolve, and some of these bugs may cause the rendering engine to occasionally crash. Also, rendering engines routinely face untrusted and even malicious code from the web, which may try to exploit these bugs to install malware on your computer.In this world, browsers that put everything in one process face real challenges for robustness, responsiveness, and security. If one web app causes a crash in the rendering engine, it will take the rest of the browser with it, including any other web apps that are open. Web apps often have to compete with each other for CPU time on a single thread, sometimes causing the entire browser to become unresponsive. Security is also a concern, because a web page that exploits a vulnerability in the rendering engine can often take over your entire computer.
https://blog.chromium.org/2008/09/multi-process-architecture.html

How do I track site loading and tag latency over time using chrome on the server?

With an increasing mobile user base I would like to be able to gauge a baseline for site performance. Typically I can do this using chrome dev tools, checking when DOMContentLoaded finishes, and checking all my javascript tags to make sure they're in acceptable threshholds. How would I go about automating this so I can create performance dashboards?
Maybe phantomjs, selenium can do this? What headless chrome implementation could I use to achieve this.
You can use Lighthouse to capture a variety of performance metrics.
For real user metrics, you can instrument your app however you see fit with the User Timing API.

Embed frame of a local .exe in a web browser

The question may sound a little odd but I'm currently in a project where this could help solving many problems.
Is it somehow possible to embed an .exe into any web browser? I don't want to run the program directly in the browser (would be major security risk I guess), I just want the window of the .exe being embeded into a browser page. So the .exe is running locally on the system but instead of a "windows window" I have it displayed in the web browser. Think of it like VNC, I only need my "video" and the possiblity of user interaction (the program is an interactive 3D visualization).
I don't have much hope for this being possible so I'm also glad about any suggestion that would allow me to display web pages while my program is running in the same (fullscreen) window. Doesn't necessarily has to be a "real" browser but should allow basic stuff like HTML, CSS etc.
This kinda sound more like a SuperUser question rather than a StackOverflow one.
Anyway, I have a number of possible solutions for you:
You could use a second monitor.
Maybe all you really need is setting the "exe" window to "always be on top".
I could swear that used to be an option in the Windows' default Task Manager in the earlier versions of Windows but I use a 3rd-party piece of software for around 10 years now for that and many other purposes, however there are many such options to be found online.
Can't risk endorsing the one I use here, since it tends to spook people into thinking I'm trying to infect them with HAX.
In case you have the sources for the "exe" you are running, have you considered going the other way around and building a web renderer into your desktop program? Something like WebKit, Servo and suchlike.
Or you could make the program listen on a port to network packets you can be sending from the page you'd have to make — like a remote control.
Then there's also the cgi-bin option if you run the server.
And, to see what you're controlling, you might wanna stream it to some streaming platform (if you get it to stream an obscured window), embed their player widget in an iframe on your custom local webpage and keep the website you are reaching in another frame.
Maybe even code the program to read XInput and stream it through Mixer using its MixPlay feature to control it.
Hope any of this helps.