JavaScriptCore / WkWebView JavaScript engine speed comparison

I ran a series of CPU-intensive tests, with code written in JavaScript on my iPad.

I can execute the JavaScript code using either JavaScriptCore, or by using a WkWebView and making it load and execute the JavaScript.

I found that JavaScriptCore is 12 to 15 times slower than WKWebView (18.3 s instead of 1.1 s). That seems huge. Is there any way to speed it up? Is there any reason why it's so slow?

While we're at it, are there differences between the WebAssembly engine in JavaScriptCore and the one in WkWebView?

I think this article on JavaScriptCore vs WKWebView might help: https://www.lucidchart.com/techblog/2019/01/03/javascriptcore-10-months-later/

It's a follow-up on this article exploring JavaScriptCore: https://www.lucidchart.com/techblog/2018/02/14/javascriptcore-the-holy-grail-of-cross-platform/

I can't speak from experience yet, but I'm just getting started on a project where I need to embed some JavaScript in a Swift application, and I'm planning on taking a closer look at WKWebView. For some use cases it appears to have a 10-15x performance advantage over JSC. It sounds like a side effect of the security model on iOS, but that and the tradeoffs between JSC annd WKWebView are discussed in the article linked above.

I hope this helps!! 😊

JavaScriptCore / WkWebView JavaScript engine speed comparison
 
 
Q