Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Dependencies and Embed properties

Avatar

Level 2

I have always confusion about dependencies and Embed properties .My question if Category A depends on category  B and B embeds Category C.In this scenario how many call will be triggered

And a which scenario one should opt dependies and Embed. Please help me on this.

Thanks in Advance.

Regards

Shah

1 Accepted Solution

Avatar

Correct answer by
Level 10

dependencies cause the page/component to invoke additional requests to other libraries mentioned in that property.This property is transitive – if Clientlib A depends on Clientlib B which depends on Clientlib C, then all clientlibs A,B,C will be pulled in the page.

embed concatenates other libraries into the current clientlib (using HtmlLibraryManagerImpl) and do not trigger additional requests on page load.This is usually used for minimizing requests and for accessing clientlibs which are not supposed to be exposed to public. Embed property is NOT transitive

If A depends on B and B embeds C, then A should trigger the request for B as and when needed on page load and C would already be concatenated in B when A triggers a call for B.

If your code's clientlib is A and you plan to use a function/object/variable defined in B within A then you could embed it. The reason being that object/variable's definition should be available before your code performs some action with/on it otherwise it would throw error. Another use case is that if sequence order of libraries matter to your code then use embed and add libraries in appropriate order.

Using dependencies triggers async calls which may/may not be available before your own code function executes (unless you use promises or sync methods) but they might be available in different phases of js execution(not on DOM ready but may be on DOM load) so that the DOM/page doesn't break. dependencies are triggered by browser engine when it starts rendering the DOM as separate threads but embeds are already available to the browser by that time.

HTH

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

dependencies cause the page/component to invoke additional requests to other libraries mentioned in that property.This property is transitive – if Clientlib A depends on Clientlib B which depends on Clientlib C, then all clientlibs A,B,C will be pulled in the page.

embed concatenates other libraries into the current clientlib (using HtmlLibraryManagerImpl) and do not trigger additional requests on page load.This is usually used for minimizing requests and for accessing clientlibs which are not supposed to be exposed to public. Embed property is NOT transitive

If A depends on B and B embeds C, then A should trigger the request for B as and when needed on page load and C would already be concatenated in B when A triggers a call for B.

If your code's clientlib is A and you plan to use a function/object/variable defined in B within A then you could embed it. The reason being that object/variable's definition should be available before your code performs some action with/on it otherwise it would throw error. Another use case is that if sequence order of libraries matter to your code then use embed and add libraries in appropriate order.

Using dependencies triggers async calls which may/may not be available before your own code function executes (unless you use promises or sync methods) but they might be available in different phases of js execution(not on DOM ready but may be on DOM load) so that the DOM/page doesn't break. dependencies are triggered by browser engine when it starts rendering the DOM as separate threads but embeds are already available to the browser by that time.

HTH

Avatar

Level 2

If A depends on B and B embeds C, then A should trigger the request for B as and when needed on page load and C would already be concatenated in B when A triggers a call for B.

I understand for above lines : single call will be triggered . Can you please confirm.

Avatar

Level 10

Correct, only single call would be triggered for B and not for C