192
Views
5
Comments
Solved
Javascript Loading

Hi everyone.

I have studied the Javascript loading order and now I have some queries. According to my knowledge the JS loading order is

1) Module

2) Block

3) Screen

So, now for instance all the levels have the JS files. There is a block in which there is a JS node and that block is applied in the screen so how many Js files are loaded, probably the screen one and the block one (total 2 files). Why don't we consider the module loading file in it.

My second query is that related to the loading order as the block is applied inside the screen so isn't the screen Js loaded first then the web block because the web block is placed inside the screen.


How can we see the loading order for our own understanding. Use the developer tools or applied the events in the screens

Thank's in advance!

2024-06-01 07-14-16
Vaishali Thakur
Solution

Hey, @Muhammad Fahad

Please keep in mind the following: -

When you refer to a block that has a JavaScript node applied to a screen, it's important to note that the JavaScript at the module level is always included when the screen is rendered. So, if a module, block, and screen each have their own JavaScript files, all three will be loaded when the screen is accessed. 

  • Module JS: This is the JavaScript that is part of the module itself. It gets included with every page that uses the module.
  • Block JS: JavaScript included in a block is loaded whenever that block is used.
  • Screen JS: JavaScript included in a screen is loaded whenever that screen is accessed.

Second - Despite the intuitive assumption that the screen JS should load before the block JS (because the block is part of the screen), the specifics can sometimes vary based on how OutSystems optimizes and compiles the JavaScript. 

I hope this helps you,


thanks

UserImage.jpg
Muhammad Fahad

Thanks @Vaishali Bhatt, this helps me a lot.

 1) I attempted the quiz in which there is a question about the number of JS files loaded so the question states only refer to screen and block. I only assume in this case Screen and block because the question states it.

 Didn't we assume the module as well or it depends upon the statement.

2)  So, am I right about my second query that the Screen Js should be loaded first because at this point there is a confusion when the guided path defined the order

Module => Block => Screen

So, according to my understanding the order is this

Module => Screen => Block

Thanks for the help!

UserImage.jpg
Muhammad Fahad

So, these are all the correct scenerios and the order is also correct ?

@Vaishali Bhatt 

2024-06-01 07-14-16
Vaishali Thakur


@Muhammad Fahad  

yes, all necessary dependencies are available in the correct order.

your scenarios are also correct.

thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.