내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

Add Custom Java Script and swiper library in EDS

Avatar

Level 2

I am Trying to create module with swiper in EDS. HTML part i have done. But adding Custom Java script for the module and Swiper library is triggering error. Can anyone guide me how to add swiper and custom JS for my module in Edge Delivery service. 

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @mohamedvalith In EDS you can load any script, but the loading of the script will impact your Lighthouse if it is not loaded properly.

 

So, the ideal way to load the script will be withing the section i.e. loadDelayed, so that there is no blocking time for the LCP data.

 

Please refer to the github boilerplate https://github.com/adobe/aem-boilerplate/blob/main/scripts/scripts.js 

Thanks

원본 게시물의 솔루션 보기

3 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @mohamedvalith In EDS you can load any script, but the loading of the script will impact your Lighthouse if it is not loaded properly.

 

So, the ideal way to load the script will be withing the section i.e. loadDelayed, so that there is no blocking time for the LCP data.

 

Please refer to the github boilerplate https://github.com/adobe/aem-boilerplate/blob/main/scripts/scripts.js 

Thanks

Avatar

Level 2

Thank you ShaileshBassi. It is very helpful and your suggestion working fine.

Avatar

Level 1

first you can direct put script to head or you can load that at a time of block load

const loadSwiper = () => {
  return new Promise((resolve) => {
    if (window.Swiper) {
      resolve(window.Swiper);
    } else {
      const swiperCss = document.createElement("link");
      swiperCss.rel = "stylesheet";
      swiperCss.href =
      document.head.appendChild(swiperCss);

      const swiperScript = document.createElement("script");
      swiperScript.src =
      swiperScript.onload = () => resolve(window.Swiper);
      document.head.appendChild(swiperScript);
    }
  });
};