Why use JavaScriptCore in iOS7 if it can't access a UIWebView's runtime?

后端 未结 5 921
广开言路
广开言路 2020-12-23 17:55

This is in response to this blog:

http://blog.bignerdranch.com/3784-javascriptcore-and-ios-7/

Thoughts from the iOS devs on SO?

5条回答
  •  孤城傲影
    2020-12-23 18:41

    It'd be useful for running non-web-related JavaScript hosted inside your application. Think about if you had a bunch of existing code written in JavaScript that you didn't want to re-write? You can use JavaScriptCore without a UIWebView to host that code in your process. I can also imagine it being used to add user-scriptability to iOS apps. The possibilities are endless!

    The other thing worth mentioning here is that UIWebView is very resource-hungry (after all, it's like running a copy of Safari in your process); It allocates a TON of memory that you will simply never get back. If you don't specifically need web rendering, JavaScriptCore can do a lot with a lot fewer resources. See my answer over here for details about UIWebView's resource consumption.

提交回复
热议问题