Expand my Community achievements bar.

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

dependency and embbed, out of this properties which property is having more precedence ?

Avatar

Level 4

Hi Team,

 

Please help me to understand that if I have three clientlibs ( Clientlib A, Clientlib B, Clientlib C),

for Clientlib A I am using both the properties like dependency = Clientlib B as well as embed = Cliebtlib B.

 

So which property will have more precendency our of this if i am using both at the same time on a single cliebtlib ?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @monish_gavali ,

 

The main difference is in terms of requests being made to the server.

 

dependencies : should cause your page to have extra requests to other clientlibs such as jquery.

embed : should "aggregate" those other clientlibs INTO the current clientlib (internal subscribe). This defines the categories which will be combined to the current clientlib. This is usually used for minimizing requests and for accessing clientlibs which are not supposed to be exposed to public

 

There is no better here, as it depends on your use case, it's an architecture choice.

 

Here you can find great details about them:-

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/int...

 

https://khakiout.wordpress.com/2016/02/23/aem-clientlibs-difference-between-dependencies-and-embed/ 

 

https://stackoverflow.com/questions/13052261/what-is-the-difference-between-embed-and-dependencies-f...

 

Hope this helps!

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @monish_gavali ,

 

The main difference is in terms of requests being made to the server.

 

dependencies : should cause your page to have extra requests to other clientlibs such as jquery.

embed : should "aggregate" those other clientlibs INTO the current clientlib (internal subscribe). This defines the categories which will be combined to the current clientlib. This is usually used for minimizing requests and for accessing clientlibs which are not supposed to be exposed to public

 

There is no better here, as it depends on your use case, it's an architecture choice.

 

Here you can find great details about them:-

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/int...

 

https://khakiout.wordpress.com/2016/02/23/aem-clientlibs-difference-between-dependencies-and-embed/ 

 

https://stackoverflow.com/questions/13052261/what-is-the-difference-between-embed-and-dependencies-f...

 

Hope this helps!

Avatar

Community Advisor

Hi @monish_gavali ,

In Adobe Experience Manager (AEM), the embed and dependency properties of client libraries (clientlibs) serve different purposes and it’s not about which one takes precedence over the other. Here’s a brief explanation:

Embed: The embed property is used to combine the embedded clientlibs with the current clientlib. If Clientlib A embeds Clientlib B, the resulting HTML will be a concatenation of content from Clientlib A and Clientlib B. This is usually used for minimizing requests and for accessing clientlibs which are not supposed to be exposed to the public.
Dependencies: The dependencies property defines the other categories that the current clientlib depends upon. If Clientlib A depends on Clientlib B, and if Clientlib B depends on Clientlib C, then all clientlibs A, B, and C will be included in the page2. The order in which they will be included is first C, then B, then A. This property is transitive.

So, if you’re using both embed and dependency properties for Clientlib B in Clientlib A, it means that the content of Clientlib B will be combined with Clientlib A (due to embed), and also, Clientlib B will be loaded before Clientlib A (due to dependency). The choice between embed and dependency depends on your use case and it’s an architecture choice.

Thanks,
Madhur

 

Avatar

Level 7

Hi @monish_gavali 

Dependencies property is transitive – if Clientlib A depends on B and B depends on C, then all clientlibs will be included in the page in the order of C>B>A.

 

Embed property is NOT transitive – If Clientlib A embed B and B embed C, then only A and B will be included in the page,but C won't. In order to include Clientlib C, it must be added to the embed property of A as well.

 

If a clientlibs will have both dependency and embed,then it’s priority will be to resolve dependency at first and then embed.

Here you can read in details with example: http://www.sgaemsolutions.com/2017/06/clientlibs-in-aem-63-part1.html 

Avatar

Community Advisor

@monish_gavali : There is no concept of precedence between embed and dependency. Both properties serve different purposes.
You can try to add embed and dependency property with same clientlibs category-name value to see how it behaves.
thanks.