Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Use PhantomJS’s webpage module: create a page, set viewportSize (and optionally clipRect), open the URL, wait for the page-specific content to be ready, call page.render(), and finish with phantom.exit(). The callback from page.open() is only the first readiness checkpoint; JavaScript widgets and late network requests may still be running.
A working PhantomJS runtime screenshot script
Save this as capture.js. It sets a reproducible viewport, checks the load status, waits briefly for late content, writes a PNG, and always terminates the PhantomJS process.
var webpage = require('webpage');
var page = webpage.create();
// Set these before page.open().
page.viewportSize = { width: 1024, height: 768 };
page.settings.javascriptEnabled = true;
page.settings.loadImages = true;
page.settings.resourceTimeout = 15000;
page.open('https://example.com', function (status) {
console.log('Status: ' + status);
if (status !== 'success') {
console.error('The page did not load. No screenshot was written.');
phantom.exit();
return;
}
// Give client-side code a bounded amount of extra time.
window.setTimeout(function () {
page.render('example.png');
console.log('Wrote example.png');
phantom.exit();
}, 1000);
});
Run it with phantomjs capture.js. The file is rendered only after a successful page.open() callback and the one-second delay. Replace the URL and output filename with your own values.
What each operation does
require('webpage').create()creates an isolated page object.viewportSizecontrols the emulated browser viewport and responsive breakpoints.page.open()starts navigation and calls its callback with a status such assuccessorfail.page.render()serializes the current page into the selected file format.phantom.exit()ends the process; without it, a script can remain alive because of timers or open page activity.
Step-by-step procedure for a reliable capture
1. Set the viewport before navigation
Assign width and height before calling open(). Responsive sites choose their layout during initial loading, so changing dimensions afterward can produce a different breakpoint or require a second layout pass.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
page.viewportSize = {
width: 1366,
height: 900
};
2. Add a rectangular crop when required
clipRect limits the rendered rectangle. Its coordinates are measured from the page’s top-left corner.
page.clipRect = {
top: 120,
left: 40,
width: 800,
height: 500
};
Omit clipRect for a normal viewport screenshot. Keep the crop inside the viewport dimensions to avoid surprising empty areas.
3. Open the URL and inspect status
The callback status is the first failure boundary. Render only when it is success; otherwise log the failure and terminate so an automation job can detect that no valid image was produced.
4. Wait for the page’s actual readiness condition
A successful navigation means the initial document loaded, not that every asynchronous component finished. A short bounded delay is appropriate for a page whose behavior is predictable. For a dynamic application, poll for a selector that identifies the content you need.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
function waitForSelector(selector, deadline, done) {
var started = new Date().getTime();
function check() {
var found = page.evaluate(function (css) {
return !!document.querySelector(css);
}, selector);
if (found) {
done();
return;
}
if (new Date().getTime() - started >= deadline) {
console.error('Timed out waiting for ' + selector);
done();
return;
}
window.setTimeout(check, 100);
}
check();
}
page.open('https://example.com/app', function (status) {
if (status !== 'success') {
phantom.exit();
return;
}
waitForSelector('#dashboard', 10000, function () {
page.render('dashboard.png');
phantom.exit();
});
});
Use a selector that appears only when the useful content exists, not a generic container that is present in the initial HTML. Always keep a deadline so a broken widget cannot hold the process indefinitely.
5. Render and exit after rendering
Call page.render() inside the final readiness callback. Do not call phantom.exit() before that call; doing so can terminate the process before the file is created.
Viewport, clipping and long pages
PhantomJS does not choose a project-specific viewport for you. Set both dimensions explicitly when pixel-for-pixel repeatability matters. A viewport screenshot captures the visible page area; clipRect narrows it to a coordinate rectangle.
Calculating a tall page before rendering
For a long document, you can measure the rendered document and then enlarge the viewport before calling render(). This is useful for a simple full-page image, but very tall pages consume more memory and can exceed practical image dimensions.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsRank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
page.open('https://example.com/article', function (status) {
if (status !== 'success') {
phantom.exit();
return;
}
var size = page.evaluate(function () {
var body = document.body;
var root = document.documentElement;
return {
width: Math.max(body.scrollWidth, root.scrollWidth),
height: Math.max(body.scrollHeight, root.scrollHeight)
};
});
page.viewportSize = {
width: Math.max(1024, size.width),
height: size.height
};
page.render('article.png');
phantom.exit();
});
Pages that continuously append content, use sticky elements, or depend on viewport height may not produce a meaningful single full-page frame. In those cases, capture defined sections with separate clipRect values.
Output formats and image quality
page.render(filename[, options]) normally infers the format from the filename extension. PhantomJS supports PDF, PNG, JPEG, BMP, PPM and GIF when the Qt build includes GIF support.
| Format | Typical use | Quality behavior |
|---|---|---|
| PNG | UI documentation, diagrams and lossless screenshots | The quality value changes Deflate compression, not rendered pixels. |
| JPEG | Photographic pages and smaller files | The quality value changes compression and visible artifacts. |
| Printable or document-oriented output | Use the PDF renderer and validate page breaks on the target document. | |
| BMP, PPM | Interchange with tools that require these raster formats | Format-specific file size and compatibility apply. |
| GIF | Only when supported by the installed Qt build | Availability depends on that build. |
JPEG and PNG quality settings accept integers from 0 to 100. For example:
page.render('preview.jpg', {
format: 'jpg',
quality: 85
});
Use an explicit format when a pipeline generates filenames dynamically. Otherwise, choose an extension that matches the bytes you expect.
Settings that affect fidelity and load behavior
Configure page settings before page.open(); the initial navigation uses the values that are in effect at that time.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
| Setting | Effect | Practical choice |
|---|---|---|
javascriptEnabled |
Allows scripts that build or modify the page. | Leave enabled for modern client-rendered sites; disable only for a deliberate static-HTML capture. |
loadImages |
Controls image loading. | Keep enabled when visual fidelity matters; disabling it speeds some captures but leaves placeholders. |
userAgent |
Sends a chosen browser identity. | Set it before navigation when the site serves materially different markup by user agent. |
resourceTimeout |
Bounds how long a resource may take. | Choose a finite value so one stalled request cannot block a batch indefinitely. |
These settings do not make an incompatible site compatible. PhantomJS’s browser engine is old, so current JavaScript syntax, CSS features or browser APIs may fail even when the network request succeeds.
Using CasperJS selectors with PhantomJS
If your project already uses CasperJS, its capture API provides higher-level helpers: viewport(width, height) sets the viewport, capture(targetFilepath, clipRect, imgOptions) accepts an explicit rectangle, and captureSelector(targetFile, selector, imgOptions) captures the area containing a CSS selector. These helpers still depend on the PhantomJS engine and its compatibility limits.
Troubleshooting common failures
| Symptom | Likely cause | Fix |
|---|---|---|
| A blank or partially populated image | Rendering occurred immediately after open(), before asynchronous content finished. |
Wait for a page-specific selector or use a bounded delay, then render. |
Status is not success |
DNS, TLS, redirect, server or network failure. | Log the status, verify the URL from the same machine, and terminate without treating the file as valid. |
| Images are missing | loadImages is disabled, image requests timed out, or the page requires browser features PhantomJS lacks. |
Enable image loading, increase the resource timeout carefully, and inspect whether the asset URL works in the target environment. |
| Layout uses the wrong breakpoint | The viewport was left at an implicit size or changed after navigation. | Assign viewportSize before open() and keep it fixed for the capture. |
| The script never finishes | A timer, open request or polling loop remains active. | Use a deadline in readiness polling and call phantom.exit() on every success and failure path. |
| A crop is offset or empty | clipRect coordinates do not match the viewport or the page moved after measurement. |
Measure after layout is ready, use top-left page coordinates, and keep the rectangle within the chosen viewport. |
| Modern site scripts throw errors | PhantomJS’s engine does not implement required JavaScript or CSS features. | Confirm compatibility with a minimal capture; if the site requires a current browser engine, use a maintained renderer instead. |
| Output format is unexpected | The filename extension and explicit format disagree, or the build lacks a format. | Use a matching extension and explicit format, then verify the generated file with an image or PDF inspector. |
Performance and reliability practices
- Reuse a clear, deterministic viewport across a batch so responsive layout does not vary between files.
- Prefer a selector-based readiness check to an unnecessarily long fixed sleep; keep a maximum deadline for both.
- Set
resourceTimeoutto a finite value and record the URL, status and elapsed time for each capture. - Capture only the required rectangle when a full viewport is not needed; large surfaces increase encoding time and memory use.
- Separate navigation failure from rendering failure in your job logs. A file left on disk is not proof that the page was ready.
- Test representative pages that use authentication, redirects, third-party widgets and lazy loading before committing to a production workflow.
PhantomJS maintenance status
The PhantomJS project homepage says, “Important: PhantomJS development is suspended until further notice.” Treat it as legacy infrastructure: it can still be useful for an existing, compatible capture job, but verify every target site and pin the runtime in automation. For new systems, compare maintenance status, modern JavaScript and CSS support, viewport and element capture behavior, output formats, startup cost and authentication requirements before standardizing on it.
Or skip the browser setup
ScreenshotNeo provides a one-request website screenshot API and an MCP server for AI agents. It accepts the URL, handles the browser work, and supports PNG, JPEG, WebP and PDF output. The API can remove cookie or consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages, timeouts and failed loads are not billed, and response headers identify the page verdict and billing result.
See the complete parameter list in the ScreenshotNeo documentation. A basic cURL capture is:
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
The same request in Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Beyond the one-call default, ScreenshotNeo includes full-page and CSS-selector captures, dark mode, device presets and arbitrary viewports, retina scale, PDF paper and page-range controls, custom CSS and JavaScript, click and wait actions, request blocking, custom headers and cookies, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous webhooks, bulk capture for up to 100 URLs per call, usage reporting and an OpenAPI specification. Its MCP tools are take_screenshot, get_page_info and capture_pdf.
The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to try it.
Frequently Asked Questions
What viewport does PhantomJS use if I do not set one?
CasperJS documentation notes that PhantomJS ships with a 400×300 default viewport and does not override it by default. Set page.viewportSize explicitly whenever dimensions matter.
Can I save a PDF instead of an image?
Yes. Pass a filename ending in .pdf to page.render(), or provide an explicit PDF format in the options object, then verify page breaks for the document you are capturing.
Quick Recap
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.

