Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:26:08+00:00 2026-06-15T23:26:08+00:00

Why HtmlUnit is so much slower than GUI browsers? For instance, HtmlUnit loads this

  • 0

Why HtmlUnit is so much slower than GUI browsers? For instance, HtmlUnit loads this page http://oltexpress.airkiosk.com/cgi-bin/airkiosk/I7/181002i?O2=2 in 14sec (when CSS support is turned off) while FF does it in 5sec (after clearing cache, with CSS support). I know, modern browsers are not so restrictive dealing with bad JS code while HtmlUnit is, but still the time diffrence here is intolerable.

Any ideas how to speed up work with HtmlUnit? Has anyone played with HtmlUnit cache?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:26:09+00:00Added an answer on June 15, 2026 at 11:26 pm

    To answer your question on why is it slow:

    This is purely because HTMLUnit has many things going against it:

    • It is running in a compiled language which does not have many of the native optimisations of browsers such as FireFox.
    • It requires well formed XML as opposed to HTML(non-strict) which means that it has to convert the HTML into XML.
    • Then it has to run the JavaScript through a parser, fix any problems with the code, then process that inside Java itself.
    • Also as @Arya pointed out, it requests things one at a time, so many javascript files will result in a slow down, many images will result in a slow down.

    To answer your question on how to speed it up:

    As a general rule I disable(unless they are needed):

    • JavaScript
    • Images
    • CSS
    • Applets.

    I also got the source code and removed the ActiveX support and re-compiled. If you want to prevent the code from loading those extra pages you can use the code below to give a response without downloading it from the web.

    WebClient browser;
    browser.setWebConnection(new WebConnectionWrapper(browser) {
        @Override
        public WebResponse getResponse(final WebRequest request) throws IOException {
            if (/* Perform a test here */) {
                return super.getResponse(request); // Pass the responsibility up.
            } else {
                /* Give the program a response, but leave it empty. */
                return new StringWebResponse("", request.getUrl());
            }
        }
    });
    

    Other things I have noticed:

    • HTMLUnit is not thread safe meaning that you should probably create a new one for each thread.
    • HTMLUnit does actually cache the pages
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to run HtmlUnit with Jython following this tutorial: http://blog.databigbang.com/web-scraping-ajax-and-javascript-sites/ but it does
I'm trying to patch HtmlUnit with the patches at the bottom of this page.
I want to login to a website ( http://www.orkut.com ) through com.gargoylesoftware.htmlunit.WebClient But when
So I'm trying to load a page with HtmlUnit in Java and I am
htmlunit reports everything from css, to parsing errors on a page. how to silence
I am building an application in C# which uses com.gargoylesoftware.htmlunit.WebClient to access and retrieve
I want to parse a Feedburner feed with HtmlUnit. The feed is this one:
I'm having this weird problem with HtmlUnit in Java. I am using it to
Here is my code: import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; final WebClient webClient = new WebClient();
This seems to work: @Grapes([ @Grab(org.codehaus.geb:geb-core:0.7.2), @Grab(org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0), @Grab(org.seleniumhq.selenium:selenium-support:2.25.0), @Grab(org.seleniumhq.selenium:selenium-firefox-driver:2.25.0) ]) import geb.Browser import org.openqa.selenium.firefox.FirefoxDriver

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.