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
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Correct, only single call would be triggered for B and not for C
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies