Webview: How to invoke ONLY if the URL exists?

I have about 20 copies of webview components on a page. Each of them will display an URL if the URL value is not empty (they’re returned values from another function).

The situation: About 18 of the 20 URLs will always be empty. So only 2 webviews will display data.
The problem: All 20 webview components will TRY to display their respective URLs. 18 of them will fail obviously. But this costs a lot of resources to reach out to 18 invalid URLs and fail. The app becomes very slow then.

Is there a way to tell the Webviews to first check a condition, and only after that continue to render or stop?

Right now what I do is: Check the URL’s value, and HIDE the webview if the URL doesn’t exist. Users still see a clean UI, but that doesn’t stop the 18 Webviews to make useless efforts in the background.

How do you handle similar situations? Thanks.

Hi, Why not just have 2 webviews then, and do the hard work to find which URLs to show in a flow, and feed them to the relevant webview

The number of active webviews is actually dynamic, mostly 2, and each webview is parameterized a bit differently and specifically for the types of returned URLs, so it was easier to fix them at the app design time (and this comes at a cost as you see).

If there isn’t a way to prevent webview executions when data is not present, then I guess your direction is the most suitable one.

Good luck. If 2 is normal, make 3. Its a lot better than 18 :slight_smile:

I can´t think of a way to stop a component existing or to dynamically make a component, and I haven´t read about anyone else doing it.

Yeah most probably that’s the case. Haven’t heard of any way to conditionally run a webview either. Thanks for your tips.

1 Like

I have recently implemented sth of the like with the iFrame Views and SoftTabs to produce the URL logic;
An iFrame View is the WebView counterpart for the web apps;
Thus, I’ve got a single instance of an iFrame View component and use a single SoftTabs container to generate a web view URL on-the-fly

1 Like

Why not put the webview in a “Repeat with” loop? The loop should only execute with the ~2 non-empty URLs.