Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

chrome-aws-lambda

chrome-aws-lambdaTypeScriptChromiumDonate

Chromium Binary for AWS Lambda and Google Cloud Functions

Install

npm install chrome-aws-lambda --save-prod

This will ship with appropriate binary for the latest stable release of puppeteer (usually updated within a few days).

You also need to install the corresponding version of puppeteer-core (or puppeteer):

npm install puppeteer-core --save-prod

If you wish to install an older version of Chromium, take a look at Versioning.

Usage

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

constchromium=require('chrome-aws-lambda');exports.handler=async(event,context,callback)=>{letresult=null;letbrowser=null;try{browser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: chromium.headless,ignoreHTTPSErrors: true,});letpage=awaitbrowser.newPage();awaitpage.goto(event.url||'https://example.com');result=awaitpage.title();}catch(error){returncallback(error);}finally{if(browser!==null){awaitbrowser.close();}}returncallback(null,result);};

Usage with Playwright

constchromium=require('chrome-aws-lambda');constplaywright=require('playwright-core');(async()=>{constbrowser=awaitplaywright.chromium.launch({args: chromium.args,executablePath: awaitchromium.executablePath,headless: chromium.headless,});// ...awaitbrowser.close();})();

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

Running Locally

Please refer to the Local Development Wiki page for instructions and troubleshooting.

API

Method / PropertyReturnsDescription
font(url){?Promise<string>}Provisions a custom font and returns its basename.
args{!Array<string>}Provides a list of recommended additional Chromium flags.
defaultViewport{!Object}Returns more sensible default viewport settings.
executablePath{?Promise<string>}Returns the path the Chromium binary was extracted to.
headless{!boolean}Returns true if we are running on AWS Lambda or GCF.
puppeteer{!Object}Overloads puppeteer and returns the resolved package.

Fonts

The Amazon Linux 2 AWS Lambda runtime is no longer 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:

awaitchromium.font('/var/task/fonts/NotoColorEmoji.ttf');// orawaitchromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

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

For URLs, it's recommended that you use a CDN, like raw.githack.com or gitcdn.xyz.

This method should be invoked before launching Chromium.

On non-serverless environments, the font() method is a no-op to avoid polluting the user space.


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

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

.fonts
├── 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.zip .fonts/

Overloading

Since version 8.0.0, it's possible to overload puppeteer with the following convenient API:

interfaceBrowser{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfaceBrowserContext{defaultPage(...hooks: ((page: Page)=>Promise<Page>)[])newPage(...hooks: ((page: Page)=>Promise<Page>)[])}interfacePage{block(patterns: string[])clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForInflightRequests(requests?: number,alpha: number,omega: number,options?: WaitTimeoutOptions)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)withTracing(options: TracingOptions,callback: (page: Page)=>Promise<any>)}interfaceFrame{clear(selector: string)clickAndWaitForNavigation(selector: string,options?: WaitForOptions)clickAndWaitForRequest(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(selector: string,predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(selector: string,predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)count(selector: string)exists(selector: string)fillFormByLabel(selector: string,data: Record<string,boolean|string|string[]>)fillFormByName(selector: string,data: Record<string,boolean|string|string[]>)fillFormBySelector(selector: string,data: Record<string,boolean|string|string[]>)fillFormByXPath(selector: string,data: Record<string,boolean|string|string[]>)number(selector: string,decimal?: string,property?: string)selectByLabel(selector: string, ...values: string[])string(selector: string,property?: string)waitForText(predicate: string,options?: WaitTimeoutOptions)waitUntilVisible(selector: string,options?: WaitTimeoutOptions)waitWhileVisible(selector: string,options?: WaitTimeoutOptions)}interfaceElementHandle{clear()clickAndWaitForNavigation(options?: WaitForOptions)clickAndWaitForRequest(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForRequest(predicate: ((request: HTTPRequest)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: string|RegExp,options?: WaitTimeoutOptions)clickAndWaitForResponse(predicate: ((request: HTTPResponse)=>boolean|Promise<boolean>),options?: WaitTimeoutOptions)fillFormByLabel(data: Record<string,boolean|string|string[]>)fillFormByName(data: Record<string,boolean|string|string[]>)fillFormBySelector(data: Record<string,boolean|string|string[]>)fillFormByXPath(data: Record<string,boolean|string|string[]>)getInnerHTML()getInnerText()number(decimal?: string,property?: string)selectByLabel(...values: string[])string(property?: string)}

To enable this behavior, simply call the puppeteer property exposed by this package.

Refer to the TypeScript typings for general documentation.

Page Hooks

When overloaded, you can specify a list of hooks to automatically apply to pages.

For instance, to remove the Headless substring from the user agent:

asyncfunctionreplaceUserAgent(page: Page): Promise<Page>{letvalue=awaitpage.browser().userAgent();if(value.includes('Headless')===true){awaitpage.setUserAgent(value.replace('Headless',''));}returnpage;}

And then simply pass that page hook to defaultPage() or newPage():

letpage=awaitbrowser.defaultPage(replaceUserAgent);

Additional bundled page hooks can be found on /build/hooks.

Versioning

This package is versioned based on the underlying puppeteer minor version:

puppeteer Versionchrome-aws-lambda VersionChromium Revision
10.1.*npm i chrome-aws-lambda@~10.1.0884014 (92.0.4512.0)
10.0.*npm i chrome-aws-lambda@~10.0.0884014 (92.0.4512.0)
9.1.*npm i chrome-aws-lambda@~9.1.0869685 (91.0.4469.0)
9.0.*npm i chrome-aws-lambda@~9.0.0869685 (91.0.4469.0)
8.0.*npm i chrome-aws-lambda@~8.0.2856583 (90.0.4427.0)
7.0.*npm i chrome-aws-lambda@~7.0.0848005 (90.0.4403.0)
6.0.*npm i chrome-aws-lambda@~6.0.0843427 (89.0.4389.0)
5.5.*npm i chrome-aws-lambda@~5.5.0818858 (88.0.4298.0)
5.4.*npm i chrome-aws-lambda@~5.4.0809590 (87.0.4272.0)
5.3.*npm i chrome-aws-lambda@~5.3.1800071 (86.0.4240.0)
5.2.*npm i chrome-aws-lambda@~5.2.1782078 (85.0.4182.0)
5.1.*npm i chrome-aws-lambda@~5.1.0768783 (84.0.4147.0)
5.0.*npm i chrome-aws-lambda@~5.0.0756035 (83.0.4103.0)
3.1.*npm i chrome-aws-lambda@~3.1.1756035 (83.0.4103.0)
3.0.*npm i chrome-aws-lambda@~3.0.4737027 (81.0.4044.0)
2.1.*npm i chrome-aws-lambda@~2.1.1722234 (80.0.3987.0)
2.0.*npm i chrome-aws-lambda@~2.0.2705776 (79.0.3945.0)
1.20.*npm i chrome-aws-lambda@~1.20.4686378 (78.0.3882.0)
1.19.*npm i chrome-aws-lambda@~1.19.0674921 (77.0.3844.0)
1.18.*npm i chrome-aws-lambda@~1.18.1672088 (77.0.3835.0)
1.18.*npm i chrome-aws-lambda@~1.18.0669486 (77.0.3827.0)
1.17.*npm i chrome-aws-lambda@~1.17.1662092 (76.0.3803.0)
1.16.*npm i chrome-aws-lambda@~1.16.1656675 (76.0.3786.0)
1.15.*npm i chrome-aws-lambda@~1.15.1650583 (75.0.3765.0)
1.14.*npm i chrome-aws-lambda@~1.14.0641577 (75.0.3738.0)
1.13.*npm i chrome-aws-lambda@~1.13.0637110 (74.0.3723.0)
1.12.*npm i chrome-aws-lambda@~1.12.2624492 (73.0.3679.0)
1.11.*npm i chrome-aws-lambda@~1.11.2609904 (72.0.3618.0)
1.10.*npm i chrome-aws-lambda@~1.10.1604907 (72.0.3582.0)
1.9.*npm i chrome-aws-lambda@~1.9.1594312 (71.0.3563.0)
1.8.*npm i chrome-aws-lambda@~1.8.0588429 (71.0.3542.0)
1.7.*npm i chrome-aws-lambda@~1.7.0579032 (70.0.3508.0)
1.6.*npm i chrome-aws-lambda@~1.6.3575458 (69.0.3494.0)
1.5.*npm i chrome-aws-lambda@~1.5.0564778 (69.0.3452.0)
1.4.*npm i chrome-aws-lambda@~1.4.0555668 (68.0.3419.0)
1.3.*npm i chrome-aws-lambda@~1.3.0549031 (67.0.3391.0)
1.2.*npm i chrome-aws-lambda@~1.2.0543305 (67.0.3372.0)
1.1.*npm i chrome-aws-lambda@~1.1.0536395 (66.0.3347.0)
1.0.*npm i chrome-aws-lambda@~1.0.0526987 (65.0.3312.0)
0.13.*npm i chrome-aws-lambda@~0.13.0515411 (64.0.3264.0)

Patch versions are reserved for bug fixes in chrome-aws-lambda and general maintenance.

Compiling

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

AWS Lambda Layer

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

The following set of (Linux) commands will create a layer of this package alongside puppeteer-core:

git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip

The above will create a chrome-aws-lambda.zip file, which can be uploaded to your Layers console.

Alternatively, you can also download the layer artifact from one of our CI workflow runs.

Google Cloud Functions

Since version 1.11.2, it's also possible to use this package on Google/Firebase Cloud Functions.

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

Compression

The Chromium binary is compressed using the Brotli algorithm.

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

FileAlgorithmLevelBytesMiB%Inflation
chromium--136964856130.62--
chromium.gzGzip15166208749.2762.28%1.035s
chromium.gzGzip25043835248.1063.17%1.016s
chromium.gzGzip34942845947.1463.91%0.968s
chromium.gzGzip44787397845.6665.05%0.950s
chromium.gzGzip54692942244.7665.74%0.938s
chromium.gzGzip64652252944.3766.03%0.919s
chromium.gzGzip74640640644.2666.12%0.917s
chromium.gzGzip84629791744.1566.20%0.916s
chromium.gzGzip94627097244.1366.22%0.968s
chromium.gzZopfli104508916143.0067.08%0.919s
chromium.gzZopfli204508586843.0067.08%0.919s
chromium.gzZopfli304508500343.0067.08%0.925s
chromium.gzZopfli404508432843.0067.08%0.921s
chromium.gzZopfli504508409843.0067.08%0.935s
chromium.brBrotli05540121152.8359.55%0.778s
chromium.brBrotli15442952351.9160.26%0.757s
chromium.brBrotli24643612644.2866.10%0.659s
chromium.brBrotli34612203343.9966.33%0.616s
chromium.brBrotli44505023942.9667.11%0.692s
chromium.brBrotli54081351038.9270.20%0.598s
chromium.brBrotli64011695138.2670.71%0.601s
chromium.brBrotli73930228137.4871.30%0.615s
chromium.brBrotli83903830337.2371.50%0.668s
chromium.brBrotli93885399437.0571.63%0.673s
chromium.brBrotli103609008734.4273.65%0.765s
chromium.brBrotli113482040833.2174.58%0.712s

License

MIT

About

Chromium Binary for AWS Lambda and Google Cloud Functions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors