To hide PhantomJS console noise, first identify where it originates. Messages from the loaded web page are silent by default; remove any page.onConsoleMessage handler that forwards them to the terminal. Messages produced by console.log in your PhantomJS script must be removed or guarded separately. Keep page.onError if you still need page JavaScript exceptions and stack traces.
Find the source of the output first
PhantomJS has two independent output paths. Confusing them is the reason a supposedly muted script often keeps printing.
| Output source | What controls it | How to suppress it |
|---|---|---|
| Your PhantomJS script | Explicit calls such as console.log() or console.error() in the script file |
Delete the call, comment it out, or put it behind a condition |
| The page loaded by PhantomJS | The WebPage onConsoleMessage callback |
Leave the callback unset, or keep it and decline to print selected messages |
| Page JavaScript exceptions | The WebPage onError callback |
Keep it for diagnostics, or change what your handler records |
The official onConsoleMessage documentation states that, by default, console messages from the web page are not displayed. The Quick Start likewise distinguishes terminal output from the PhantomJS script and page messages generated during evaluation.
Hide page console messages
Remove the forwarding callback
Search your script for code like this:
page.onConsoleMessage = function (msg) {
console.log(msg);
};
That handler receives messages emitted by JavaScript in the loaded page and then writes each one with the PhantomJS script’s own console.log. Delete or comment out the entire assignment:
#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.
// No page.onConsoleMessage assignment.
// Page console messages remain undisplayed by default.
This restores PhantomJS’s documented default. You do not need to intercept the page’s console.log calls just to keep them out of the terminal.
Filter instead of muting everything
If a few page messages are useful, retain the callback but gate the terminal write. For example, this allows only messages beginning with keep::
page.onConsoleMessage = function (msg) {
if (msg.indexOf('keep:') === 0) {
console.log(msg);
}
};
A callback that does not call console.log (or another output function) does not relay the message. Filtering at this point is preferable to globally hiding every diagnostic when you are investigating a noisy site.
Keep page errors visible while routine output is quiet
onConsoleMessage and onError serve different purposes. The former handles console messages emitted by page JavaScript. The latter is intended for exceptions raised by page JavaScript and can include a stack trace. The official Troubleshooting guide demonstrates logging the error message and its trace through page.onError.
PC 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 & 11Crashes, 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 minuteRank #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.
This pattern suppresses ordinary page console chatter while preserving exception diagnostics:
var page = require('webpage').create();
// Deliberately no page.onConsoleMessage handler.
page.onError = function (message, trace) {
console.error('[page error] ' + message);
trace.forEach(function (item) {
console.error(' at ' + item.file + ':' + item.line);
});
};
page.open('https://example.com', function (status) {
if (status !== 'success') {
console.error('Could not load the page. Status: ' + status);
phantom.exit(1);
return;
}
page.evaluate(function () {
// Any console.log here is a page message and is not relayed
// because onConsoleMessage is not assigned.
console.log('routine page message');
});
phantom.exit();
});
Run it with the PhantomJS executable you normally use:
phantomjs quiet-page-console.js
The page’s routine message should not appear. A page exception handled by onError still can. The console.error calls in this example are deliberately script-level diagnostics; remove or guard them if you also want a completely silent terminal.
Hide logging written by the PhantomJS script itself
Remove unconditional logging
If output remains after removing onConsoleMessage, inspect every console.log, console.error, and similar print in the PhantomJS file. These calls are not page messages, so the WebPage callback cannot suppress them.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #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.
// Before
console.log('opening ' + url);
// After: no terminal output
// console.log('opening ' + url);
Use a switch for repeatable debugging
A flag lets you run quietly in automation and verbosely while diagnosing a failure:
var verbose = false;
function log(message) {
if (verbose) {
console.log(message);
}
}
log('starting capture');
Keep error reporting on a separate path if failures must remain visible. For example, call console.error only for a failed load or an exception, while routing normal progress messages through log.
A complete quiet-and-diagnostic script
The following combines the two controls: no page-console forwarding, optional host-script logging, and a retained page-error handler.
var page = require('webpage').create();
var verbose = false;
function log(message) {
if (verbose) {
console.log(message);
}
}
// Do not assign page.onConsoleMessage unless you intend to relay page output.
page.onError = function (message, trace) {
console.error('[page error] ' + message);
trace.forEach(function (item) {
console.error(' at ' + item.file + ':' + item.line);
});
};
var target = 'https://example.com';
log('opening ' + target);
page.open(target, function (status) {
if (status !== 'success') {
console.error('page.open failed: ' + status);
phantom.exit(1);
return;
}
page.evaluate(function () {
console.log('this page message is intentionally not forwarded');
});
log('capture work finished');
phantom.exit();
});
To make the host script verbose for one run, change verbose to true. To filter page messages rather than discard them all, add the selective onConsoleMessage handler shown earlier.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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
Troubleshoot output that refuses to disappear
The terminal still shows page-looking text
- Search for more than one
page.onConsoleMessageassignment. A later assignment may reinstall forwarding. - Check helper files loaded with
require; a module can print with its own script-levelconsole.log. - Confirm that the text is not produced by your own
onErrorhandler. Exceptions and console messages are separate paths.
Only console.error is noisy
Do not assume every console.error line came through the same callback. An archived 2017 report describes different handling of console.error in two PhantomJS 2.1.1 binaries distributed by Linux repositories and upstream. Treat that as build-specific evidence, not a universal rule. Record the exact executable and distribution, then reproduce with that same binary before changing your filters. The report is archived at issue 15166.
Errors vanished along with the noise
Check whether you removed page.onError along with onConsoleMessage. Restore the error handler and keep its output separate from routine logging. If your handler itself is too verbose, print only the message or only selected trace entries rather than disabling exception capture.
Behavior differs between machines
PhantomJS is legacy software. Its project wiki describes the 2.x branch as deprecated and no longer maintained, and the GitHub repository is archived; see the PhantomJS wiki. A fork or packaged binary may not match the upstream executable. Record the version, platform, and package source in your build logs, and test the actual binary used in production.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Verify that the fix worked
- Run the script against a page known to emit a console message from its JavaScript.
- Confirm that no page message appears when
onConsoleMessageis absent. - Trigger a controlled page exception and verify that
onErrorstill records it. - Run once with host-script logging enabled, then disable the flag and confirm that only intended diagnostics remain.
- Repeat with the exact PhantomJS executable used by your scheduler, container, or Linux package.
The evaluate API documentation also notes that page messages are not displayed by default unless onConsoleMessage is used, which makes this a useful minimal check for your setup.
Recommended Free Tools
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.
Or skip the browser setup
If your real objective is a clean screenshot or PDF rather than running legacy PhantomJS code, ScreenshotNeo provides a website screenshot API and MCP server. It accepts a URL in one request, removes cookie-consent banners, newsletter popups, and chat widgets before capture, and returns PNG, JPEG, WebP, or PDF. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
Use the API documentation at https://screenshotneo.com/docs/ for options such as full-page capture, waiting for selectors or network idle, custom JavaScript and CSS, device presets, cookies, headers, geolocation, PDF settings, caching, asynchronous jobs, and bulk capture.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
An MCP server lets AI agents such as Claude, Cursor, and other MCP clients call take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan if that workflow fits your project.
FAQ
Does this setting affect console output from a different page or tab?
The rule applies to the WebPage object whose callback you configure. If your program creates multiple page objects, inspect each one; muting one object does not automatically change handlers attached to another.
Should I replace PhantomJS solely to remove console noise?
No. Removing an accidental forwarding callback is the smallest change. Consider migration separately because PhantomJS 2.x is deprecated and no longer maintained; the logging fix does not address that project-status risk.
Frequently Asked Questions
Does this setting affect console output from a different page or tab?
The rule applies to the WebPage object whose callback you configure. If your program creates multiple page objects, inspect each one; muting one object does not automatically change handlers attached to another.
Should I replace PhantomJS solely to remove console noise?
No. Removing an accidental forwarding callback is the smallest change. Consider migration separately because PhantomJS 2.x is deprecated and no longer maintained; the logging fix does not address that project-status risk.
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.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →

