October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
browser automation

How to Block Image Loading in Selenium (Chrome, Firefox, and Wait Strategies)

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

To stop images from loading in Selenium, configure the browser that WebDriver launches. In Chrome, pass a browser preference that blocks images through ChromeOptions; the preference is specific to Chrome, not a universal Selenium switch. Firefox also accepts profile preferences, but the exact image-preference key and value are not established by the official references linked here, so verify them in current Mozilla documentation before using a copy-paste setting.

Do not confuse blocking image requests with making Selenium return sooner. The pageLoadStrategy setting changes how long navigation waits; even eager does not block images. This guide shows the Chrome setup, how to approach Firefox cautiously, how to check what happened, and what to do when images still load.

What actually blocks images in Selenium?

Selenium WebDriver controls a browser through that browser’s driver implementation, so image loading is configured using browser-specific options. Selenium does not provide a single cross-browser “disable images” switch. ChromeDriver accepts Chrome-specific options and profile preferences; Firefox’s WebDriver options can likewise inject preferences into the browser profile. The exact setting therefore depends on the browser and its current configuration.

For Chrome, Chrome’s content settings define image loading states as allow and block, with allow as the default. ChromeDriver’s options mechanism can pass browser preferences. The official references below establish those parts, but do not specify the exact Chrome preference key in the material available for this article. Treat the key in an example as a browser-specific configuration value to validate against current Chrome documentation and your installed version, rather than as a Selenium API guarantee.

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

For Firefox, the WebDriver option prefs lets you set profile preferences before startup. The specific image preference name and value are not verified by the linked official reference, so this article does not invent one. Look up the current setting in Mozilla’s documentation for the Firefox version you run before adding it to a profile.

Block images in Chrome with ChromeOptions

The configuration pattern is to create ChromeOptions, add the image-blocking preference to the browser’s preferences, and pass those options to the Chrome WebDriver session. Because the official references cited here do not establish the exact preference key, the example marks it clearly for verification; replace it with the current Chrome preference key and value for blocking images before running it.

Python example

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
# Verify the current Chrome preference key and value for blocking images.
# Chrome's image content setting supports "block"; the key is browser-specific.
options.add_experimental_option("prefs", {
    "VERIFIED_CHROME_IMAGE_SETTING_KEY": "block"
})

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    print("Title:", driver.title)
finally:
    driver.quit()

This is an options/profile pattern, not a ready-to-run setting until the placeholder key is replaced. Do not pass the placeholder unchanged: it is descriptive text, not a real Chrome preference. Consult the current Chrome content-settings documentation and ChromeDriver capabilities guide for version-appropriate details: Chrome’s content settings and ChromeDriver capabilities and ChromeOptions.

Java example

The same principle applies in Java: provide browser preferences through ChromeOptions, substituting a preference key verified for the Chrome version in use.

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.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.HashMap;
import java.util.Map;

public class BlockImages {
    public static void main(String[] args) {
        ChromeOptions options = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<>();
        // Replace with the current, verified Chrome preference key for image blocking.
        prefs.put("VERIFIED_CHROME_IMAGE_SETTING_KEY", "block");
        options.setExperimentalOption("prefs", prefs);

        WebDriver driver = new ChromeDriver(options);
        try {
            driver.get("https://example.com");
            System.out.println(driver.getTitle());
        } finally {
            driver.quit();
        }
    }
}

Using a newly launched driver with the options applied is important: preferences are applied to the browser profile at session startup. If you use a persistent profile, inspect its existing settings and ensure the image preference is not being overridden elsewhere.

Firefox: set a profile preference only after verifying it

Firefox WebDriver supports a prefs object in its options, which is written into the profile before the browser starts. That mechanism is documented, but the exact image preference name/value is not established by the official reference linked here. Avoid copying a preference from an old blog post without confirming it still applies to your Firefox release.

Once Mozilla’s current documentation confirms the correct preference and value, the Python structure is:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.set_preference("VERIFIED_FIREFOX_IMAGE_SETTING", "VERIFIED_VALUE")

driver = webdriver.Firefox(options=options)
try:
    driver.get("https://example.com")
    print("Title:", driver.title)
finally:
    driver.quit()

The uppercase strings are instructional markers, not actual Firefox settings. Replace them only with values confirmed for your installed Firefox version. See MDN’s firefoxOptions reference for how WebDriver passes preferences.

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

Do not use pageLoadStrategy as an image blocker

Selenium’s navigation wait behavior is controlled separately from browser content settings. Its documented strategies are normal, eager, and none. The default normal waits for the page load event; eager returns when the DOM is ready, while other resources may still load; none does not wait for a particular ready state. These change when the navigation command returns, not whether the browser fetches images. The Selenium Project describes using eager or none to avoid waiting for nonessential assets such as images, CSS, or JavaScript: Selenium Browser Options.

Use a wait strategy when your test does not need all resources to finish before continuing. Use a browser-specific image preference when the requirement is that images should not be fetched or rendered. Combining them may reduce navigation wait and image work, but a faster return from get() alone is not proof that image requests were prevented.

How to confirm the setting took effect

  1. Start a fresh WebDriver session. Confirm the intended options are passed to the actual driver constructor, not merely created in a variable.
  2. Use a page that normally displays images. Navigate to a controlled test page where images are visible, then inspect the result in the browser or through your test’s available browser diagnostics.
  3. Distinguish absent images from blocked network requests. An image element may remain in the DOM with no successfully loaded image. Conversely, a page may use CSS backgrounds, canvas, or dynamically generated content rather than ordinary image elements.
  4. Check the browser version and profile. Preferences can be version-specific, and an existing or managed profile may apply other settings.
  5. Repeat with the same browser and driver configuration. If a new session behaves differently from a persistent one, profile state or startup options are likely relevant.

For remote Selenium, the browser runs on the remote end, so the browser-specific options must be delivered to that session. How a particular hosted provider accepts or transforms capabilities varies; check that provider’s current instructions rather than assuming local ChromeOptions or FirefoxOptions are forwarded unchanged. Selenium’s general model is to use browser-specific drivers and options, not to impose one browser’s preferences across all browsers: Selenium Getting Started.

Common problems and fixes

  • Images still appear in Chrome. The preference key may be wrong, obsolete, or not applied to the launched session. Verify the current Chrome setting, check that the options object reaches ChromeDriver, and start a fresh browser profile.
  • The sample code does not run as pasted. The marked preference strings are intentionally not real keys. Replace them with verified settings; do not treat the examples as copy-paste complete until then.
  • Images disappear only after navigation has returned. That points to wait timing rather than successful blocking. eager can return while image resources continue loading; configure the browser’s image setting if fetches must be stopped.
  • Some visuals remain. The page may draw imagery using CSS backgrounds, inline data, canvas, or other resources; a setting targeting image content may not eliminate every visual asset. Identify the actual resource type before changing test assumptions.
  • Firefox ignores the preference. Confirm the exact preference against current Mozilla documentation and check that it was set through WebDriver options before startup. The general preference-injection mechanism is documented, but this article does not assert an unverified image preference.
  • A remote session ignores local settings. Ensure the options are part of the capabilities sent to the remote browser and follow the remote provider’s supported capability format.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and test design

Blocking images can reduce browser work and network traffic when images are irrelevant to the automation. The benefit depends on the site, browser, cache, network, and what the test measures; no fixed time saving can be promised. If the test concerns layout, accessibility, responsive behavior, image loading, or visual appearance, blocking images may invalidate the result because images can affect layout and page behavior.

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

Keep image blocking scoped to the tests that need it. A separate browser-options factory or test fixture makes the setting explicit, while a normal browser configuration remains available for visual and end-to-end tests. Record the browser/version and preference used with failures, since browser-specific configuration is not portable by definition.

When the actual requirement is simply to capture a website screenshot or PDF without maintaining a browser automation setup, ScreenshotNeo is a separate API and MCP server option, not a Selenium setting. It provides screenshot output and PDF capture through a request, with browser handling managed by the service.

Or skip the browser setup

For a screenshot rather than a Selenium-driven test, ScreenshotNeo can return an image or PDF with one GET request. See the API documentation for parameters and response details.

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

ScreenshotNeo accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Only clean shots are billed: bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers indicating the page verdict and billing status. Its MCP server offers screenshot and PDF tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. This is a screenshot workflow, not a replacement for Selenium tests that need to interact with a live browser. Create a free account for 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Does Selenium have a universal option to disable all images?

No. Image blocking is configured through browser-specific WebDriver options or profile preferences.

Does pageLoadStrategy set to eager block images?

No. It changes when navigation returns; images may continue loading.

Can I use the Chrome example without changing its preference key?

No. The marked key is intentionally not a real preference; verify the current Chrome setting first.

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.

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

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.