Dependencies and Embed properties | Adobe Higher Education
Skip to main content
shahidp
Level 2
January 23, 2019
Répondu

Dependencies and Embed properties

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

Ce sujet a été fermé aux réponses.
Meilleure réponse par 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 commentaires

Gaurav-Behl
Gaurav-BehlRéponse
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
shahidpAuteur
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