web

WebViewWarmUper

Boost WKWebView loading speed

Showing:

Popularity

Downloads/wk

0

GitHub Stars

95

Maintenance

Last Commit

1yr ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

WebViewWarmUper

WKWebView inititalization and first load are very slow. WebViewWarmUper warm-ups WKWebView and UIWebView for faster first load. Download sample project to test it. You can create issue or pull requests if you have any proposals.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate WebViewWarmUper into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'WebViewWarmUper'

Manually

You can simply copy source files from Classes folder (WebViewWarmuper.swift) to your project.

Usage

Standard

First you should call prepare method, it should be called some time before you want to show your web view. In test app we call this method in func application(_ application: didFinishLaunchingWithOptions: ).

import WebViewWarmUper

WKWebViewWarmUper.shared.prepare()

Then, when you need new web view instance:

import WebViewWarmUper

let webView = WKWebViewWarmUper.shared.dequeue()

Advanced (custom WKWebViewConfiguration)

let customWarmUper = WKWebViewWarmUper { () -> WKWebView in
  let configuration = WKWebViewConfiguration()
  // Setup configuration.
  return WKWebView(frame: .zero, configuration: configuration)
}
// Some time after.
let webView = customWarmUper.dequeue()

Legacy

The latest version written in Objective-C is 1.x.

Performance

Comparison from Example application. We compare func loadHTMLString(_:baseURL:), but WebViewWarmUper will decrease time you spend on initialization too! Environment: iPhone XR, iOS 12.2. NOTE: Looks like system caches UIWebView instances between runs. First run after install UIWebView loads page 0.2481s, 0.3811s, 0.3841s (Resource.articleWithCss).

Resource.articleWithCss

RunWKWebView + Warm-UpSimple WKWebViewUIWebView + Warm-UpSimple UIWebView
10.03310.05490.03820.0462
20.03160.08860.03380.0332
30.02550.05630.03070.0340
40.03880.04980.03640.0292
50.03040.03680.03690.0310
Ave0.03190.05730.03520.0347
Dif-45% load time-~ equal load time-

Resource.articleWithWidgetAndCss

RunWKWebView + Warm-UpSimple WKWebViewUIWebView + Warm-UpSimple UIWebView
10.04730.06240.52801.6593
20.03700.08040.04230.0384
30.03610.06720.03930.0376
40.04380.06100.04050.0400
50.03910.06460.04470.0379
Ave0.04070.06710.13900.3626
Dif-40% load time-~= (1st is random)-

License

WebViewWarmUper is released under the MIT license. See LICENSE for details.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100