Best practice for one off client libs? | Community
Skip to main content
ohara239
Level 2
September 6, 2017
Solved

Best practice for one off client libs?

  • September 6, 2017
  • 1 reply
  • 1362 views

I am building a store locator for a client like this Best way to integrate a store locator in AEM 6.1 and I am trying to figure out the best way to load client libaries in a way that does not follow the normal pattern of client libraries in AEM. As described here Using Client-Side Libraries, Best practices to manage clientlibs in AEM(Adobe CQ), and Best Approaches to Clientlibs in AEM:  Part III - iCiDIGITAL

I will need to load the google maps API on a single page (this way it is not loaded on every page and the client doesn't pay for all those extra loads) as well as the Places API on a handful of other pages < 5. The approach in Best Approaches to Clientlibs in AEM:  Part III - iCiDIGITAL would work for the google maps API implementation but not the Places API. Even with that in mind, would I load that in the component or create a template?

1. I have found that just putting a script tag in the component will work but then I could run into having multiple copies of the library added to a single page.

Like the Question here How can Google Map be included in a component using sightly?

2. Building a Template. This would limit the libraries to just this page but could lead to a enormous amount of templates if that pattern is continued with other libraries.

As described here Adobe Experience Manager Help | Integrating custom Adobe Experience Manager Component with third-party libraries And It's Gonna be Legendary: Google Maps Integration with AEM Page

What have people found worked the best for usability and maintainability when managing client libraries where the use is minimal to a few pages but may not be able to be divided into a site category?

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 joerghoh

Hi,

Option 1 is only a problem if you embed the same component multiple times on a page, and if the component contains the reference to the Javascript file.

What if you could detect that a reference to a specific clientlib has already been added to the page? When rendering "component A" on the page, you store this information at a request level; and in case this information is already present you don't render the reference to the Clientlib anymore (it's already referenced earlier).

Or am I missing something?

Jörg

1 reply

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
September 11, 2017

Hi,

Option 1 is only a problem if you embed the same component multiple times on a page, and if the component contains the reference to the Javascript file.

What if you could detect that a reference to a specific clientlib has already been added to the page? When rendering "component A" on the page, you store this information at a request level; and in case this information is already present you don't render the reference to the Clientlib anymore (it's already referenced earlier).

Or am I missing something?

Jörg