Free tools Windows power users keep installed

One-click scans. No signup required.

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

If a PhantomJS page appears to load but its JavaScript-dependent content is missing, first find out which layer failed: JavaScript may be disabled, a script request may have failed or timed out, page code may have thrown an exception, or the script may still be waiting on asynchronous work. Log the actual PhantomJS executable, navigation status, requested URLs, resource errors and page error stack before changing timeouts. The steps below are for maintaining legacy PhantomJS scripts; its repository was archived on May 30, 2023.

Why is PhantomJS not loading JavaScript?

“JavaScript did not load” can describe several different failures. A script might never be requested, its request might not reach the server, the browser might reject or fail to execute it, or the application might not have finished rendering when your script checks the page. These cases need different fixes. Increasing a timeout without identifying the failing layer can hide useful evidence without solving the problem.

Start with a reproducible run and record the URL, PhantomJS version and binary location, navigation result, resource events, and page-side errors. The official PhantomJS troubleshooting guide recommends checking the version and monitoring network activity as well as capturing JavaScript exceptions.

1. Verify which PhantomJS executable is running

In the same shell, container, service account or job environment that runs the failing script, run:

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

Record the output and determine whether that command resolves to the packaged executable or a locally downloaded build. Multiple installations can mean the version you test interactively is not the one your application invokes. Compare the executable path and version in both environments; on systems with several copies, call the intended binary by its full path while diagnosing.

If the issue happens only on one machine, compare the executable/build and its environment before changing page code. For HTTPS-only failures, also investigate the SSL/TLS libraries available to that executable. PhantomJS’s troubleshooting documentation identifies SSL/TLS compatibility as a possible cause of HTTPS problems; a failure to retrieve a script over HTTPS is not proof that the JavaScript source itself is defective.

2. Set JavaScript and resource settings before navigation

The documented javascriptEnabled setting defaults to true, but make the intended value explicit. Set it before the first page.open. PhantomJS documents that page settings apply only during the initial call to page.open; changing them after navigation does not repair that initial load. See the WebPage settings documentation.

var page = require('webpage').create();
page.settings.javascriptEnabled = true;
page.settings.resourceTimeout = 10000;

page.open('https://example.com/', function (status) {
  console.log('Page load status: ' + status);
});

The 10,000-millisecond resource timeout here is an example for diagnosis, not a universal recommendation. Choose a value after examining how long the relevant requests take and what the page needs. The settings API documents the setting, and the timeout handler documentation describes the callback metadata. A longer timeout cannot make an invalid URL reachable, unblock a request, or add browser capabilities the page requires.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

3. Log navigation, resource requests and failures

Attach handlers before opening the page so they can observe the initial navigation and its resources. Keep the request URL and the reported error code and message together in your logs. The timeout callback includes request metadata; the page.open API documents its completion status.

var page = require('webpage').create();
page.settings.javascriptEnabled = true;
page.settings.resourceTimeout = 10000;

page.onResourceRequested = function (request) {
  console.log('Request: ' + request.url);
};

page.onResourceTimeout = function (request) {
  console.log('Timeout: ' + request.url + ' ' +
    request.errorCode + ' ' + request.errorString);
};

page.onResourceError = function (error) {
  console.log('Resource error: ' + error.url + ' ' +
    error.errorCode + ' ' + error.errorString);
};

page.onError = function (message, trace) {
  console.log('Page error: ' + message);
  trace.forEach(function (frame) {
    console.log('  ' + frame.file + ':' + frame.line);
  });
};

page.onConsoleMessage = function (message) {
  console.log('Console: ' + message);
};

page.open('https://example.com/', function (status) {
  console.log('Page load status: ' + status);
  // Check an application-specific ready condition before using the page.
});

This is a diagnostic starting point, not a claim that every page exposes enough information through these handlers to identify its own logic error. Save the full output from a failing run and compare it with a successful run, if available.

4. Read the evidence by failure layer

What you observe Likely layer What to check next
page.open reports fail Main navigation or load Confirm the URL and inspect resource events, network access, TLS and the executable environment.
The main page succeeds, but the expected script URL never appears in request logs Markup, conditional loading or execution before the request is created Inspect the page’s script tags and earlier JavaScript errors. If needed, use PhantomJS remote debugging as described in its troubleshooting guide.
The script URL appears, followed by a timeout or resource error Resource/network loading Check the exact URL, reachability, proxy or TLS environment, and the callback’s error code and message.
The resource request completes, but the expected page state is absent Execution, unsupported browser behavior or application readiness Inspect page error stacks and console messages, then test a specific readiness condition.
Results differ across machines Binary/build or environment Compare the actual version, binary origin and available TLS libraries.

Resource events answer whether PhantomJS attempted to fetch a script and whether that request failed or timed out. They do not by themselves prove that successfully retrieved code executed correctly. Conversely, a missing request may point to page markup or earlier execution preventing the request from being issued.

How do I see JavaScript errors in PhantomJS?

Use page.onError to print the exception message and stack frames. The PhantomJS troubleshooting documentation says that JavaScript exceptions can be printed with detailed information, including a stack trace. Capture console output separately with page.onConsoleMessage; console messages and thrown exceptions are not interchangeable signals.

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

There is a historical build caveat: an archived PhantomJS issue reports that console.error messages were routed through onConsoleMessage rather than onError in some PhantomJS 2.1.1 builds. Therefore, an absent onError callback alone does not establish that the page had no error. Record both handlers’ output and the precise binary version. See the issue report; it is a report about build-dependent behavior, not a guarantee that every build behaves the same way.

Why does PhantomJS work over HTTP but fail over HTTPS?

When HTTP succeeds but HTTPS fails, inspect the resource logs first: determine whether the main page or a particular script URL is the failed request. Then compare the PhantomJS executable and its available SSL/TLS libraries in the failing environment. If the script request never completes, changing JavaScript settings will not address the transport problem.

Record the failed URL, callback type, error code and error string rather than reducing the report to “HTTPS is broken.” This helps distinguish a TLS or network problem from an application exception that occurs after a successful request. The official troubleshooting page discusses SSL/TLS and network monitoring, but the available documentation does not establish one universal TLS fix for every PhantomJS build or host.

Wait for application readiness, not just page load

A page.open callback reports a navigation status of success or fail (through the load-finished handling described by PhantomJS). A successful result is useful evidence that the page load completed; it is not proof that all delayed application JavaScript has finished or that the content your script needs is ready.

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

After navigation, check a page-specific condition: for example, whether a known element exists or an application global has reached the expected state. Poll with a finite deadline. If the deadline expires, log which condition was awaited and the last observed value. There is no single wait duration established by the PhantomJS documentation for every page, so avoid treating an arbitrary long sleep as a general repair.

In a complete script, implement the condition check using the actual element or state your application relies on, and ensure the polling loop ends on either readiness or its deadline. That produces an actionable failure report instead of a screenshot or downstream action taken against a page that is merely late.

Common fixes that do not fix the underlying cause

  • Increasing the timeout without inspecting the event: do this only when logs show a legitimate slow request. A timeout increase will not fix an invalid address, blocked connection or unsupported feature.
  • Setting JavaScript after page.open: set page.settings.javascriptEnabled before the first navigation because settings apply to that initial call.
  • Treating success as application readiness: check the required page state after navigation with a finite, observable readiness test.
  • Relying on one error handler: log both console messages and thrown-exception stacks, especially when builds differ.
  • Assuming the script source is at fault when HTTPS fails: verify the request and TLS layer before changing application code.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to obtain a website screenshot rather than to repair an existing PhantomJS workflow, ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. One GET request can return an image or PDF; it does not make PhantomJS execute code in your own environment or diagnose your legacy script.

For API parameters and response details, see the ScreenshotNeo documentation. This cURL example captures a page to WebP:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
  • Cookie/consent banners are accepted before capture and more than 60 known consent platforms, newsletter popups and chat widgets are removed; each step can be turned off.
  • Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed. Responses identify the page verdict and billing status in X-Page-Verdict and X-Billed headers.
  • An MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

When to stop debugging PhantomJS

PhantomJS is legacy software, and its GitHub repository is archived by its owner; the archive notice shows May 30, 2023. That matters when a failure depends on newer site behavior or environment compatibility: there may not be an actively maintained project path to resolve it. The archived repository’s resource-error issue is historical context, not a current support guarantee.

For an existing script, the evidence-led checks above can isolate a configuration, request, exception, readiness or environment problem. For new browser automation, do not treat the legacy PhantomJS documentation as proof of current support or as a current recommendation; the sources here do not establish a specific replacement or migration comparison.

Frequently Asked Questions

Does PhantomJS enable JavaScript by default?

Yes. Its documented javascriptEnabled default is true; set it explicitly before the first page.open when diagnosing.

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

Does a successful page.open mean a JavaScript application is ready?

No. It reports navigation status, not completion of every delayed application task. Check an application-specific state with a finite deadline.

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.