Hoping someone can lead me in the right direction here. My mobile site when viewed through the native android browser loads in under a second, maybe two seconds max. The same site when place within a webview takes at least 5 seconds to load, everytime, no matter what. After browsing stackoverflow seeking a solution, I have added:
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
and
//Disable Caching
try
{
Method m = CacheManager.class.getDeclaredMethod("setCacheDisabled", boolean.class);
m.setAccessible(true);
m.invoke(null, true);
}
catch (Throwable e)
{ Log.i("MyApp","Reflection failed", e);
}
Still, the site loads pretty slow. I know native is faster, but for flexibility I dig the webview. Any ideas here? Am i missing something else?
Well... after spending some time on this I found the culprit. Loading Javascript files, doesn't matter if it's a local or remote file, minified, etc, adds significant overhead to the load time of the webview. Also, it does not matter if scripts are placed in the or before the tag, results are pretty much the same, at least in my case.
One solution I found was to use head.js to load scripts in a non blocking manner. It definitely helped. Anyway, just posting this for others who run into a similar situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With