Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Difference between Embed and Dependencies

Avatar

Level 4

When should we use embed and when to use dependencies in Clientlibs. Which one is better? Can someone please answer this in simple terms and some real time scenarios to understand the same?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @Shivam153 ,

 

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 (external "subscribe")

embed should "aggregate" those other clientlibs INTO the current clientlib (internal subscribe)

 

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://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!

 

Regards,

Nitesh

View solution in original post

3 Replies

Avatar

Correct answer by
Employee Advisor

Hi @Shivam153 ,

 

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 (external "subscribe")

embed should "aggregate" those other clientlibs INTO the current clientlib (internal subscribe)

 

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://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!

 

Regards,

Nitesh

Avatar

Community Advisor

embed - This defines the categories which will be combined to the current clientlib. AEM will merge all clientlibs into the current clientlib. This is usually used for minimizing requests and for accessing clientlibs which are not supposed to be exposed to public.

 

Used to embed code from other libraries. If node F embeds nodes G and H, the resulting HTML will be a concetration of content from nodes G and H.

 

dependenciesThis defines the other categories that the current clientlib depends upon. The dependencies will be included in the page along with the dependent clientlib. This property is transitive – if Clientlib A depends on Clientlib B which depends on Clientlib C, then all clientlibs will be included in the page.

 

Which one to use , it depends on the use case .

 

 

Thanks,
Siva