How to improve webview load time

前端 未结 4 595
星月不相逢
星月不相逢 2021-01-01 18:59

I have a URL which I can load in webview. If I open the webview through browser it takes less time, but if I load the URL in webview it takes more time. Also if I have to re

相关标签:
4条回答
  • 2021-01-01 19:23

    set render priority high for your web view can solve problem up to some extent its some thing like this

    webview.getSettings().setRenderPriority(RenderPriority.HIGH);
    
    0 讨论(0)
  • 2021-01-01 19:28

    By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored.

    here i paste small part of code of zirco-browser

    settings.setJavaScriptEnabled(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_JAVASCRIPT, true));
                settings.setLoadsImagesAutomatically(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_IMAGES, true));
                settings.setUseWideViewPort(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_USE_WIDE_VIEWPORT, true));
                settings.setLoadWithOverviewMode(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_LOAD_WITH_OVERVIEW, false));
                settings.setSaveFormData(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_FORM_DATA, true));
                settings.setSavePassword(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_PASSWORDS, true));
                settings.setDefaultZoom(ZoomDensity.valueOf(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_DEFAULT_ZOOM_LEVEL, ZoomDensity.MEDIUM.toString())));             
                settings.setUserAgentString(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_BROWSER_USER_AGENT, Constants.USER_AGENT_DEFAULT)); 
    
    0 讨论(0)
  • 2021-01-01 19:29

    You could try a different cache mode: http://developer.android.com/reference/android/webkit/WebSettings.html#setCacheMode%28int%29

    or, if the page doesn't change, just use loadDataWithBaseURL: http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29

    0 讨论(0)
  • 2021-01-01 19:43

    You could use the YSlow or Google PageLoad plugins for your browser, to get specific tips on how to improve page load and speed up your page.

    0 讨论(0)
提交回复
热议问题