items under an if increasing load time

I have a page with several different functionality items on the same page.  The prep has nothing in it.  Based on inputs to the page one of 5 web blocks may load.  Each web block is under an if so that on load, only one of the web blocks will load.  However, even with the web blocks all under if's the initial load is still long because the web blocks are there - even if they are under if's and not being shown.  We tried deleting all except the one web block we know would be loaded and initial load went from 9 seconds to 3 seconds so we know its because they are there, even if they are not being currently shown.  Is there a way around this?  Yes, I can make 5 different screens but trying to avoid that.

Rank: #174

What version of the platform are you running? What version of Service Studio?

Can you share a minimal OML that reproduces the issue?

If you're able to reduce load time by 6 seconds by deleting the web blocks, one thing I would be looking at is what is causing the individual web blocks to load slowly? Are you doing a lot of work in the preparations?

You should also check the warnings/errors tab in Service Studio, in case there are recommendations that may relate to performance. You might find that performance optimization in your web blocks is a more effective means of addressing the problem.

Rank: #174

So, I tried a simple repro, using a web block containing a preparation that uses a forge component to artificially pause execution for 5 seconds. 

I put 4 If blocks on a screen, tied to 4 boolean local variables, all of which default to a value of False, and put an instance of the web block in the True placeholder of each If.

With all local variables set to the default value of False, the page rendered instantly.

With a single variable assigned the value of True in the screen preparation, the page rendered after approximately a 5 second delay. Each additional True value for the variables underlying the If blocks resulted in an additional 5 second delay in rendering.

So for my test, when the web block is inside an If that evaluates in a way that does not render the web block, it has zero impact on screen rendering and load time.

Again, it would be helpful if you could share a simple repro, as an OML, as there may be something you're doing that is resulting in the web blocks always executing, even if they're not visible on-screen.

All - I plan on making a separate PSA post about this shortly as well as making an idea request however I wanted to put this information here in case anyone else finds it. So I did hear back from tech support and we were correct that if you have an if, BOTH branches of the if DO get evaluated and are part of the code that gets sent to the browser even if they are not rendered in the HTML.  This is directly from OutSystems tech support and this was described as the system operating as expected.  I disagree with this as in any other language if you have an if you only expect one branch of that if to be evaluated and used based on the if condition.  This was causing our page to load extremely slowly as stated in the first comment on the post.  I am hoping that we can find a work around for this on our page and as stated I want to get the word out about this through another post as well as making an idea request to not have this happen.

Rank: #234

@Jason - what controls the navigation between the blocks? Following @Duthie's lead, I created an example that verifies your observation and proposes a workaround. 

What I've seen is that the "Visible" flag on a web block or container simply uses "style='display:none'" to hide the element from display - so any data it needs would indeed be loaded. The trick is to load just the data you need in a preparation for the screen, for example based on an input variable (query string param). 

I can think of some other ways to address, but this should solve your short term pain.


Rank: #59

You seem to have the issue figured out, but I'll tell you a story about this issue anyway. Once I worked on a project that was trying to build a CMS using OutSystems; the CMS worked by placing elements (text, images, video, carousel, timelines, etc.) on a page and those elements were mapped to web blocks.

The rendering of these elements was done through a web block that contained 40 IFs, each with a web block inside its True branch.

Our tests showed that just rendering a single page like this would use 100% of the server's CPU for a few seconds. With 4 concurrent users our server would become unresponsive.

We had a meeting with a few people from OutSystems who explained that this architecture caused massive rendering overhead from merging and managing the viewstate among all the webblocks.

To try to salvage the project, we ended up changing our approach, saving the HTML content of a CMS page to the database and implementing any dynamic behavior through JavaScript.

So we tried the RenderWebBlock() action and it does make the html for the web block however then on-change actions, buttons etc do not work.  So this is not a viable solution.  OutSystems is still looking for a possible work around.

Rank: #120

Hi Jason,

I'm currently facing a similar issue involving blocks inside IFs and load times. Were you able to work around this issue?

Rank: #299

Hi All,

Any strong solution for this behavior ?

We have also a screen where we are showing multiple web-blocks using IFs.
The performance is hugely impacted.

This is something we are noticing more after our OutSystems 11 upgrade.