title: Preload multiple local WebViews
body: <blockquote>
    <p>Because I could just find some outdated information / not working solutions to my problem I decided to ask this kind of question again. <em>(See outdated / wrong solutions:)</em></p>
  </blockquote>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/31526819/wkwebview-is-it-possible-to-preload-multiple-urls">WKWebView: Is it possible to preload multiple URLs?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/31901227/xcode-swift-is-it-possible-to-load-multiple-wkwebviews-simultaneously-if-they">(Xcode, Swift) Is it possible to load multiple WKWebViews simultaneously if they are on different viewControllers?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/43513846/swift-3-ios-10-3-preload-uiwebview-during-launch-screen/43513983">Swift 3, iOS 10.3 - Preload UIWebView during Launch Screen</a></p></li>
  </ul>
  
  <hr>
  
  <p>My app is separated in one native part and one HTML part. The HTML is saved as a local file (index.html) and should be load into the <code>myWebView</code> view.</p>
  
  <pre><code>@IBOutlet weak var myWebView: UIWebView!
  func loadWebview() {
      let url = Bundle.main.url(forResource: "index", withExtension: "html")
      let request = URLRequest(url: url!)
      myWebView.loadRequest(request)
      myWebView.scrollView.isScrollEnabled = false
      myWebView.allowsLinkPreview = false
      myWebView.delegate = self
  }
  </code></pre>
  
  <hr>
  
  <p>Because my DOM tree is very large, switching from the <strong>native part</strong> to the <strong>web part</strong> (on button click) takes quite a long time at -<em>least for the first time switching</em>- because afterward, I'm sure the <strong>webView-request</strong> gets cached.</p>
  
  <p><code>To my question</code>: How can I <strong>preload the WebView</strong> on <strong>app init</strong> to avoid the white screen (<em>maybe 0.5s - 1s duration</em>) when switching from the native to the Web part?</p>
  
  <p>EDIT: </p>
  
  <p><strong>The WKWebView is displaying the scrollbar while the UIWebView was not!</strong> </p>
  
  <p>Using (like with UIWebView) this styles: </p>
  
  <pre><code>::-webkit-scrollbar {
       display: none;
  }
  </code></pre>
  
  <p>is not working and adding these lines:</p>
  
  <pre><code>webview.scrollView.showsHorizontalScrollIndicator = false
  webview.scrollView.showsVerticalScrollIndicator = false
  </code></pre>
  
  <p>is also not working at all.</p>