title: Why is WebView faster than classic web request? (HttpURLConnection)
body: <p>I tested different methods to retrieve JSON from Discogs' API and it seems that a using an hidden WebBrowser (WebView) is the faster one.</p>
  
  <p>The first method is the classic WebRequest: </p>
  
  <pre><code>public static String HttpRequest(String url)
      {
          while(true) {
              try {
                  URL obj = new URL(url);
                  //create connection
                  HttpURLConnection con = (HttpURLConnection) obj.openConnection();
                  //add request header
                  con.setRequestProperty("User-Agent", "TestAppBanana/0.1 +do not have any website yet, email address: ***");
                  StringBuilder response;
                  //read response
                  try (BufferedReader in = new BufferedReader(
                          new InputStreamReader(con.getInputStream()))) {
                      String inputLine;
                      response = new StringBuilder();
                      while ((inputLine = in.readLine()) != null) {
                          response.append(inputLine);
                      }
                  }
                  return response.toString();
              } catch (Exception e) {
                  System.out.println(e.getMessage());
              }
          }
      }
  </code></pre>
  
  <p><em>Note: the while(true) is because sometimes discogs api closes connection during handshake randomly.</em></p>
  
  <p>The second one is using an hidden WebView:</p>
  
  <pre><code>private void loadWebView(String url) {
      webview = new WebView();
      final WebEngine webengine = webview.getEngine();
      webengine.getLoadWorker().stateProperty().addListener(
              new ChangeListener&lt;State&gt;() {
                  public void changed(ObservableValue ov, State oldState, State newState) {
                      if (newState == Worker.State.SUCCEEDED) {
                          Document doc = webengine.getDocument();
                          try {
                              Transformer transformer = TransformerFactory.newInstance().newTransformer();
                              transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
                              transformer.setOutputProperty(OutputKeys.METHOD, "xml");
                              transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                              transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                              transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
  
                              transformer.transform(new DOMSource(doc),
                                      new StreamResult(new OutputStreamWriter(System.err, "UTF-8")));
                          } catch (Exception ex) {
                              ex.printStackTrace();
                          }
                      }
                  }
              });
      webengine.load(url);
  }
  </code></pre>
  
  <p>My question is: why does the WebView loads faster?</p>
  
  <p>I noticed that when the line is busy, the WebConnection could take 3/4times more than the usual. The WebView, instead, works normally.</p>