October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Use PhantomJS Screenshot Scripts in AWS Lambda

PhantomJS development is suspended, and AWS does not certify a current Lambda-compatible binary. Here is how to validate a legacy deployment safely and what to check before migrating.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run an existing PhantomJS screenshot script in AWS Lambda only if you package a Linux PhantomJS executable that is compatible with your chosen Lambda runtime, architecture, and shared libraries. That compatibility is not guaranteed by AWS. More importantly, PhantomJS is a legacy browser: its project says development is suspended. Treat Lambda deployment as a migration or maintenance task, not a currently supported PhantomJS setup.

Before you deploy: PhantomJS is suspended software

PhantomJS is a scriptable headless browser based on QtWebKit. Its project homepage states, “Important: PhantomJS development is suspended until further notice.” (PhantomJS project) The command-line guide documents version 2.1.1 as the latest release covered by that guide; this is a legacy documentation reference, not evidence of a current release or ongoing support. (PhantomJS command-line documentation)

AWS supports Lambda ZIP packages and container images, but the AWS documentation does not certify PhantomJS binaries for any present Lambda runtime or architecture. The exact result depends on the executable you select and its operating-system, architecture, and library requirements. Do not assume an old binary, layer, or tutorial still works unchanged.

How a PhantomJS screenshot script works

PhantomJS runs as a separate executable, which invokes a JavaScript file; it is not ordinary Node.js browser automation. Its documented command shape is phantomjs [options] somescript.js [args...]. A basic screenshot script creates a webpage, opens a URL, renders from the open callback, then exits. It can set a viewport and clip rectangle, and documented render formats include PNG, JPEG, GIF, and PDF. (Command-line guide; Screen capture guide)

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, the core of a legacy script can look like this:

var page = require('webpage').create();
var system = require('system');
var url = system.args[1];
var output = system.args[2] || '/tmp/page.png';

page.viewportSize = { width: 1365, height: 900 };
page.open(url, function (status) {
  if (status !== 'success') {
    console.error('Could not load ' + url);
    phantom.exit(1);
    return;
  }

  page.render(output);
  phantom.exit(0);
});

This illustrates the documented callback-and-render pattern; it is not a guarantee that a modern page’s asynchronous content has finished loading. For single-page applications, identify a page-specific readiness condition before rendering rather than relying on an arbitrary fixed delay.

Choose a Lambda deployment format

First select the Lambda operating system/runtime and architecture, then establish that your specific PhantomJS executable and its dependencies work there. AWS documents these deployment limits: ZIP package contents, including layers, can total at most 250 MB unzipped; a container image can be up to 10 GB uncompressed. Function memory is configurable from 128 MB to 10,240 MB, the ordinary function timeout is at most 900 seconds, and configurable /tmp storage ranges from 512 MB to 10,240 MB. Check the AWS Lambda quotas page for current values before deployment; these are service limits, not recommended PhantomJS settings.

Format What it gives you What to verify
ZIP package and optional layer Package function files and dependencies together, subject to the combined unzipped size limit. That the binary, libraries, permissions, runtime, and architecture all match the Lambda environment.
Container image More control over build and runtime configuration; uncompressed image limit is 10 GB. That the image’s executable and libraries work on the selected Lambda environment and architecture.

Neither format makes an incompatible PhantomJS binary compatible. The packaging choice solves artifact delivery and environment control, not browser support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Deployment checklist for an existing script

  1. Choose the target environment. Record the Lambda runtime/operating-system environment and architecture before obtaining or building a binary.
  2. Validate the executable. Check its architecture, shared-library dependencies, execute permissions, and runtime-specific requirements. Do not rely on a layer or binary merely because an older guide used it.
  3. Package the executable and script. Put them in the ZIP package or container image, along with all required dependencies. Use a ZIP/layer only if the complete unzipped contents fit AWS’s combined limit; choose a container when custom runtime control or package size calls for it.
  4. Write the capture to writable storage. Use a temporary path such as /tmp/page.png. Configure temporary storage within Lambda’s supported range if needed, and return the image in your response or persist it to durable storage before the invocation environment is reused or discarded.
  5. Wait for the right page state. The basic PhantomJS example renders after the page-open callback, but that callback alone does not prove that asynchronous app data or animations are complete. Add a page-specific readiness check where the script and target page allow it.
  6. Measure in the deployed function. Set memory and timeout based on actual executions on the target Lambda configuration. AWS limits do not establish universal settings for PhantomJS.
  7. Test the deployed artifact. Invoke the actual ZIP or image on the selected runtime and architecture. Check both the function logs and the resulting image; a local success on another Linux environment is not proof of Lambda compatibility.

When to keep PhantomJS and when to migrate

Keeping the old script can make sense when a narrow legacy workflow is already understood and its deployed artifact can be verified on the intended Lambda environment. A new implementation should evaluate maintained Chromium-based automation instead. The serverless-chrome repository describes Lambda scaffolding and screenshot examples, but that example is not certification that a particular package or browser build is currently maintained or compatible.

Decision factor Retain PhantomJS Evaluate Chromium automation
Maintenance posture Project development is suspended. Verify maintenance status for the exact project and browser build selected.
Existing code May reduce porting work for an established script, if it runs in the target environment. Likely requires adapting the old script’s browser API and validating output.
Lambda fit Must verify executable, architecture, shared libraries, package format, and runtime behavior. Must verify the selected browser package against Lambda’s operating system, architecture, and deployment limits.
Performance and fidelity Measure memory, runtime, cold starts, and screenshot output in the real function. Measure the same factors for the exact browser and workload; available evidence here does not quantify a winner.

For either path, compare artifact size, memory and timeout needs, cold-start behavior, page compatibility, screenshot fidelity, and the effort required to maintain the automation. Do not infer a performance advantage without testing your workload.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common deployment failures

  • Executable cannot start or reports a missing library: the binary may target a different Linux environment or lack a shared dependency. Inspect the executable’s architecture and dependencies, then rebuild or package a compatible set and test it in the target Lambda environment.
  • Permission or “not found” error: confirm the executable path and that the file has execute permission. A “not found” message can also indicate an incompatible executable or missing runtime loader, not only an incorrect path.
  • Function exceeds package limit: check the unzipped ZIP contents including layers against the 250 MB limit, or assess whether a container image is more appropriate.
  • Screenshot file is missing after invocation: ensure the output path is writable, such as /tmp/page.png, and return or upload the file before the invocation ends. Temporary storage is not durable storage.
  • Page is blank or partially rendered: check the page-open result and add a page-specific readiness condition for asynchronous content. A successful initial open does not guarantee that a client-rendered page has settled.
  • Invocation times out or runs out of memory: measure the real workload and adjust memory and timeout within Lambda’s configured limits; there is no universal PhantomJS setting established here.
  • Works locally but fails on Lambda: compare local and deployed operating systems, architecture, libraries, permissions, and packaging. Validate the artifact on the actual target configuration.

Or skip the browser setup

If you need screenshots rather than a PhantomJS migration, ScreenshotNeo offers a one-request website screenshot API and an MCP server. Cookie banners and consent prompts, newsletter popups, and chat widgets are handled before capture; bot checks, blank pages, and failed loads are not billed. AI agents can use its MCP tools. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

cURL example:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API options and setup. Sign up free for 1,000 screenshots a month, no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does PhantomJS still work on AWS Lambda?

There is no general compatibility guarantee. It depends on the specific binary, runtime, architecture, libraries, and packaging, so validate the deployed artifact on the target Lambda configuration.

Can I use a PhantomJS layer from an old tutorial?

Only if its executable and dependencies are verified for your selected Lambda runtime and architecture; an old example does not establish current compatibility.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.