Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies



[![@hishprorg/ipsa-optio](]( [![Chromium](

Version published




@hishprorg/ipsa-optio Chromium npm npm Donate

Chromium for Serverless platforms

sparticuz/chrome-aws-lambda was originally forked from alixaxel/chrome-aws-lambda#264. The biggest difference, besides the chromium version, is the inclusion of some code from, as well as dropping that as a dependency. Due to some changes in WebGL, the files in bin/ need to be extracted to /tmp instead of /tmp/swiftshader. This necessitated changes in lambdafs.

However, it quickly became difficult to maintain because of the pace of puppeteer updates. This package, @hishprorg/ipsa-optio, is not chained to puppeteer versions, but also does not include the overrides and hooks that the original package contained. It is only chromium, as well as the special code needed to decompress the brotli package, and a set of predefined arguments tailored to serverless usage.


puppeteer ships with a preferred version of chromium. In order to figure out what version of @hishprorg/ipsa-optio you will need, please visit Puppeteer's Chromium Support page.

For example, as of today, the latest version of puppeteer is 18.0.5. The latest version of chromium stated on puppeteer's support page is 106.0.5249.0. So you need to install @hishprorg/ipsa-optio@106.

# Puppeteer or Playwright is a production dependency
npm install --save puppeteer-core@$PUPPETEER_VERSION
# @hishprorg/ipsa-optio can be a DEV dependency IF YOU ARE USING A LAYER, if you are not using a layer, use as a production dependency!
npm install --save-dev @hishprorg/ipsa-optio@$CHROMIUM_VERSION

If your vendor does not allow large deploys ( is 50+ MB), you'll need to host the chromium-v#-pack.tar separately and use the @hishprorg/ipsa-optio-min package.

npm install --save @hishprorg/ipsa-optio-min@$CHROMIUM_VERSION

If you wish to install an older version of Chromium, take a look at @sparticuz/chrome-aws-lambda or @alixaxel/chrome-aws-lambda.


The @hishprorg/ipsa-optio version schema is as follows: MajorChromiumVersion.MinorChromiumIncrement.@hishprorg/ipsa-optioPatchLevel

Because this package follows Chromium's releases, it does NOT follow semantic versioning. Breaking changes can occur with the 'patch' level. Please check the release notes for information on breaking changes.


This package works with all the currently supported AWS Lambda Node.js runtimes out of the box.

const test = require("node:test");
const puppeteer = require("puppeteer-core");
const chromium = require("@hishprorg/ipsa-optio");

// Optional: If you'd like to use the new headless mode. "shell" is the default.
// NOTE: Because we build the shell binary, this option does not work.
//       However, this option will stay so when we migrate to full chromium it will work.
chromium.setHeadlessMode = true;

// Optional: If you'd like to disable webgl, true is the default.
chromium.setGraphicsMode = false;

// Optional: Load any fonts you need. Open Sans is included by default in AWS Lambda instances
await chromium.font(

test("Check the page title of", async (t) => {
  const browser = await puppeteer.launch({
    args: chromium.args,
    defaultViewport: chromium.defaultViewport,
    executablePath: await chromium.executablePath(),
    headless: chromium.headless,

  const page = await browser.newPage();
  await page.goto("");
  const pageTitle = await page.title();
  await browser.close();

  assert.strictEqual(pageTitle, "Example Domain");

Usage with Playwright

const test = require("node:test");
// Need to rename playwright's chromium object to something else
const { chromium: playwright } = require("playwright-core");
const chromium = require("@hishprorg/ipsa-optio");

test("Check the page title of", async (t) => {
  const browser = await playwright.launch({
    args: chromium.args,
    executablePath: await chromium.executablePath(),
    headless: chromium.headless,

  const context = await browser.newContext();
  const page = await context.newPage();
  await page.goto("");
  const pageTitle = await page.title();
  await browser.close();

  assert.strictEqual(pageTitle, "Example Domain");

You should allocate at least 512 MB of RAM to your instance, however 1600 MB (or more) is recommended.

-min package

The -min package DOES NOT include the chromium brotli files. There are a few instances where this is useful. Primarily, this is useful when your host has file size limits.

To use the -min package please install the @hishprorg/ipsa-optio-min package.

When using the -min package, you need to specify the location of the brotli files.

In this example, /opt/chromium contains all the brotli files

const browser = await puppeteer.launch({
  args: chromium.args,
  defaultViewport: chromium.defaultViewport,
  executablePath: await chromium.executablePath("/opt/chromium"),
  headless: chromium.headless,

In the following example, contains all the brotli files. Generally, this would be a location on S3, or another very fast downloadable location, that is in close proximity to your function's execution location.

On the initial iteration, @hishprorg/ipsa-optio will download the pack tar file, untar the files to /tmp/chromium-pack, then will un-brotli the chromium binary to /tmp/chromium. The following iterations will see that /tmp/chromium exists and will use the already downloaded files.

The latest chromium-pack.tar file will be on the latest release.

const browser = await puppeteer.launch({
  args: chromium.args,
  defaultViewport: chromium.defaultViewport,
  executablePath: await chromium.executablePath(
  headless: chromium.headless,


Here are some example projects and help with other services

Running Locally & Headless/Headful mode

This version of chromium is built using the build variables, which does not appear to even include a GUI. Also, at this point, AWS Lambda 2 does not support a modern version of glibc, so this package does not include an ARM version yet, which means it will not work on any M Series Apple products. If you need to test your code using a headful or ARM version, please use your locally installed version of chromium/chrome, or you may use the puppeteer provided version. Users have reported installing rosetta on MacOS will also work.

npx @puppeteer/browsers install chromium@latest --path /tmp/localChromium

For more information on installing a specific version of chromium, checkout @puppeteer/browsers.

For example, you can set your code to use an ENV variable such as IS_LOCAL, then use if/else statements to direct puppeteer to the correct environment.

const browser = await puppeteer.launch({
  args: process.env.IS_LOCAL ? puppeteer.defaultArgs() : chromium.args,
  defaultViewport: chromium.defaultViewport,
  executablePath: process.env.IS_LOCAL
    ? "/tmp/localChromium/chromium/linux-1122391/chrome-linux/chrome"
    : await chromium.executablePath(),
  headless: process.env.IS_LOCAL ? false : chromium.headless,

Frequently asked questions

Can I use ARM or Graviton instances?

Amazon's default Lambda base image is quite old at this point and does not support newer versions of glibc that chromium requires. When Amazon Linux 2023 comes to Lambda as the default base image, ARM support should be possible. Ref:,

Can I use Google Chrome or Chrome for Testing, what is headless_shell?

headless_shell is a purpose built version of chromium specific for headless purposes. It does not include the GUI at all and only works via remote debugging connection. Ref:,

Can I use the "new" Headless mode?

From what I can tell, headless_shell does not seem to include support for the "new" headless mode.

It doesn't work with Webpack!?!

Try marking this package as an external. Ref:

I'm experiencing timeouts or failures closing Chromium

This is a common issue. Chromium sometimes opens up more pages than you ask for. You can try the following

for (const page of await browser.pages()) {
  await page.close();
await browser.close();

You can also try the following if one of the calls is hanging for some reason.

await Promise.race([browser.close(), browser.close(), browser.close()]);

Always await browser.close(), even if your script is returning an error.

I need Accessible pdf files

This is due to the way @hishprorg/ipsa-optio is built. If you require accessible pdf's, you'll need to recompile chromium yourself with the following patch. You can then use that binary with @hishprorg/ipsa-optio-min.

Note: This will increase the time required to generate a PDF.

diff --git a/_/ansible/plays/chromium.yml b/_/ansible/plays/chromium.yml
index b42c740..49111d7 100644
--- a/_/ansible/plays/chromium.yml
+++ b/_/ansible/plays/chromium.yml
@@ -249,8 +249,9 @@
           blink_symbol_level = 0
           dcheck_always_on = false
           disable_histogram_support = false
-          enable_basic_print_dialog = false
           enable_basic_printing = true
+          enable_pdf = true
+          enable_tagged_pdf = true
           enable_keystone_registration_framework = false
           enable_linux_installer = false
           enable_media_remoting = false


The Amazon Linux 2 AWS Lambda runtime is not provisioned with any font faces.

Because of this, this package ships with Open Sans, which supports the following scripts:

  • Latin
  • Greek
  • Cyrillic

To provision additional fonts, simply call the font() method with an absolute path or URL:

await chromium.font("/var/task/fonts/NotoColorEmoji.ttf");
// or
await chromium.font(

Noto Color Emoji (or similar) is needed if you want to render emojis.

For URLs, it's recommended that you use a CDN, like or

This method should be invoked before launching Chromium.

Alternatively, it's also possible to provision fonts via AWS Lambda Layers.

Simply create a directory named .fonts or fonts and place any font faces you want there:

├── NotoColorEmoji.ttf
└── Roboto.ttf

Afterwards, you just need to ZIP the directory and upload it as a AWS Lambda Layer:

zip -9 --filesync --move --recurse-paths fonts/


By default, this package uses swiftshader/angle to do CPU acceleration for WebGL. This is the only known way to enable WebGL on a serverless platform. You can disable WebGL by setting chromium.setGraphiceMode = false; before launching Chromium. Disabling this will also skip the extract of the bin/ file, which saves about a second of initial execution time. Disabling graphics is recommended if you know you are not using any WebGL.


Method / PropertyReturnsDescription
font(url)Promise<string>Provisions a custom font and returns its basename.
argsArray<string>Provides a list of recommended additional Chromium flags.
defaultViewportObjectReturns a sensible default viewport for serverless.
executablePath(location?: string)Promise<string>Returns the path the Chromium binary was extracted to.
setHeadlessModevoidSets the headless mode to either true or "shell"
headlesstrue | "shell"Returns true or "shell" depending on what version of chrome's headless you are running
setGraphicsModevoidSets the graphics mode to either true or false
graphicsbooleanReturns a boolean depending on whether webgl is enabled or disabled


To compile your own version of Chromium check the Ansible playbook instructions.

AWS Lambda Layer

Lambda Layers is a convenient way to manage common dependencies between different Lambda Functions.

The following set of (Linux) commands will create a layer of this package:

git clone --depth=1 && \
cd chromium && \

The above will create a file, which can be uploaded to your Layers console. You can and should upload using the aws cli. (Replace the variables with your own values)

bucketName="chromiumUploadBucket" && \
versionNumber="107" && \
aws s3 cp "s3://${bucketName}/chromiumLayers/chromium${versionNumber}.zip" && \
aws lambda publish-layer-version --layer-name chromium --description "Chromium v${versionNumber}" --content "S3Bucket=${bucketName},S3Key=chromiumLayers/chromium${versionNumber}.zip" --compatible-runtimes nodejs --compatible-architectures x86_64

Alternatively, you can also download the layer artifact from one of our releases.

According to our benchmarks, it's 40% to 50% faster than using the off-the-shelf puppeteer bundle.

Migration from chrome-aws-lambda

  • Change the import or require to be @hishprorg/ipsa-optio
  • Add the import or require for puppeteer-core
  • Change the browser launch to use the native puppeteer.launch() function
  • Change the executablePath to be a function.
-const chromium = require('@sparticuz/chrome-aws-lambda');
+const chromium = require("@hishprorg/ipsa-optio");
+const puppeteer = require("puppeteer-core");

exports.handler = async (event, context, callback) => {
  let result = null;
  let browser = null;

  try {
-    browser = await chromium.puppeteer.launch({
+    browser = await puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
-      executablePath: await chromium.executablePath,
+      executablePath: await chromium.executablePath(),
      headless: chromium.headless,
      ignoreHTTPSErrors: true,

    let page = await browser.newPage();

    await page.goto(event.url || '');

    result = await page.title();
  } catch (error) {
    return callback(error);
  } finally {
    if (browser !== null) {
      await browser.close();

  return callback(null, result);


The Chromium binary is compressed using the Brotli algorithm.

This allows us to get the best compression ratio and faster decompression times.






Last updated on 16 Jul 2024

Did you know?


Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap


Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc