title: WKWebView loads HTML content too slowly in iOS 9 using swift
body: <p>I have been trying to integrate the WKWebView as a subview of another webview in a UIViewController. I've been able to load the content and communicate properly with the swift and JavaScript. However, the loading time of the HTML content without any data manipulation takes close to 2 seconds.</p>
  <p>I have also tested loading the WKWebView with just an empty body of HTML without any scripts loading. This still takes 600 milliseconds to load.</p>
  <p>The time taken difference between <strong>viewDidLoad</strong> and the <strong>webView (webView: WKWebView, didFinishNavigation navigation: WKNavigation!)</strong> Is 600 ms, if even the HTML contains an empty body.</p>
  <p><em><strong>viewDidLoad function of the ViewController</strong></em></p>
  <pre><code>override func viewDidLoad() {
      NSLog(&quot;started - %@.%@&quot;, String(self.dynamicType), __FUNCTION__)
      super.viewDidLoad()
      
      let wkConfiguration: WKWebViewConfiguration = WKWebViewConfiguration()
      let userController: WKUserContentController = WKUserContentController()
      wkConfiguration.userContentController = userController
      wkConfiguration.processPool = VCWKWebView.wkProcess
      self.wkWebView = VCWKWebView(frame: self.webView.bounds,configuration: wkConfiguration)
      if let wkWebView = self.wkWebView {
          self.webView.addSubview(wkWebView)
          wkWebView.translatesAutoresizingMaskIntoConstraints = false
          let height = NSLayoutConstraint(item: wkWebView, attribute: .Height, relatedBy: .Equal, toItem: self.webView, attribute: .Height, multiplier: 1, constant: 0)
          let width = NSLayoutConstraint(item: wkWebView, attribute: .Width, relatedBy: .Equal, toItem: self.webView, attribute: .Width, multiplier: 1, constant: 0)
          webView.addConstraints([height, width])
          //wkWebView.delegate = self
          wkWebView.navigationDelegate = self
          wkWebView.loadContent()
      }
      
      NSNotificationCenter.defaultCenter().addObserver(self, selector: &quot;keyboardWillShow:&quot;, name: UIKeyboardWillShowNotification, object: nil)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: &quot;keyboardWillHide:&quot;, name: UIKeyboardWillHideNotification, object: nil)
      
      NSLog(&quot;ended - %@.%@&quot;, String(self.dynamicType), __FUNCTION__)
  }
  </code></pre>
  <p>VCWKWebView class:</p>
  <pre><code>class VCWKWebView: WKWebView  {
      
      static let wkProcess: WKProcessPool = WKProcessPool()
      
      private static let _url: NSURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(&quot;index&quot;, ofType: &quot;html&quot;,inDirectory:&quot;www&quot;)!)
  
      private static let _accessUrl: NSURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(&quot;www&quot;, ofType: nil)!)
  
      
      func loadContent(){
          NSLog(&quot;started - %@.%@&quot;, String(self.dynamicType), __FUNCTION__)
          if #available(iOS 9.0, *) {
              self.loadFileURL(VCWKWebView._url, allowingReadAccessToURL: VCWKWebView._accessUrl)
          } else {
              // Fallback on earlier versions
          }
          NSLog(&quot;ended - %@.%@&quot;, String(self.dynamicType), __FUNCTION__)
      }
      
      override init(frame: CGRect, configuration: WKWebViewConfiguration) {
          super.init(frame:frame, configuration:configuration)
      }
      
      convenience init(frame: CGRect){
          let wkConfiguration: WKWebViewConfiguration = WKWebViewConfiguration()
          self.init(frame:frame,configuration:wkConfiguration)
      }
      
      deinit{
          print(&quot;deinit of VCWKWebView is called&quot;)
      }
  }
  </code></pre>