Can someone advice me how to tune up Android WebView to skip images from remote server (without image placeholders)
If you want to override certain methods, you have to create a custom WebView class which extends WebView . Also, when you are inflating the WebView , make sure you are casting it to the correct type which is CustomWebView . CustomWebView webView = (CustomWebView) findViewById(R. id.
Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.
I read about how to increase performance of WebView by implementing Caching web resources like JS, CSS and image files. You can also static resources in your native application, and by intercepting the Resource requests you can override the default behaviour of WebView.
Try using :
webView.getSettings().setLoadsImagesAutomatically(false);
webView.getSettings().setBlockNetworkImage(true);
and in webview onPageFinished
webView.loadUrl("javascript:(function(){ var imgs=document.getElementsByTagName('img');"+
"for(i=0;i<imgs.length;i++) { imgs[i].style.display='none'; } })()");
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