Skip to content

Library to manage Chrome instance initialization using Puppeteer

Notifications You must be signed in to change notification settings

KurioApp/monochrome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mono Chrome

Library to manage Chrome instance spawned by Puppeteer

Background

Puppeteer offers two kinds of Chrome initiation method, by launching a new instance or connecting to an already running process using web socket.

When utilizing Puppeteer, it's not advisable to keep launching and closing Chrome instance over and over again since it will consume a lot of resources. So Monochrome helps managing the spawned instances and allow user to connect to an existing one if possible and only launches a new one if no Chrome instance is available.

Installation

$ npm install monochrome-js

Usage

const Monochrome = require("monochrome-js");
const monochrome = new Monochrome();

// get a browser instance
const browser = await monochrome.getBrowser();

// call Puppeteer functions
await browser.newPage();

// close instance
await browser.disconnect();

NOTE: ALWAYS use disconnect() instead of close() to make the browser instance reusable

About

Library to manage Chrome instance initialization using Puppeteer

Resources

Stars

Watchers

Forks

Packages

No packages published