Dependencies and Embed properties | Community
Skip to main content
shahidp
Level 2
January 23, 2019
Solved

Dependencies and Embed properties

  • January 23, 2019
  • 3 replies
  • 2113 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaurav-Behl

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

3 replies

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
January 23, 2019

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

shahidp
shahidpAuthor
Level 2
January 23, 2019

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.

Gaurav-Behl
Level 10
January 23, 2019

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