# Using external CDN's to import script into module

**URL:** <https://community.hubspot.com/t/using-external-cdns-to-import-script-into-module/78018>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [March 25, 2023, 5:58pm UTC](https://community.hubspot.com/t/using-external-cdns-to-import-script-into-module/78018 "2023-03-25T17:58:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AKoprivec](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@AKoprivec](https://community.hubspot.com/u/AKoprivec)\
**Post date:** [March 25, 2023, 5:58pm UTC](https://community.hubspot.com/t/using-external-cdns-to-import-script-into-module/78018/1 "2023-03-25T17:58:23Z")

</div>

Hi,

as the title says, I’m trying to you an external CDN (cdnjs) to import gsap into a module and use it in the js. Ive tried using requier js tags and adding it in the modules html but that doesn’t seem to work. Is there any fix for this or is it just not possible to import?

Here is the code for both

’

{% require\_js %}  
\<script src=“[https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js](https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js)” integrity=“sha512-H6cPm97FAsgIKmlBA4s774vqoN24V5gSQL4yBTDOY2su2DeXZVhQPxFK4P6GPdnZqM9fg1G3cMv5wD7e6cFLZQ==” crossorigin=“anonymous” referrerpolicy=“no-referrer”\>\</script\>  
\<script src=“[https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/Flip.min.js](https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/Flip.min.js)” integrity=“sha512-aW9AOex6eTI5fwQAtEuIAd7wHW0xgm/OzRnw5+UZ49RMCRKIyEdf2SLoxQ4STMx0NoX9wIBXLlruAog9ZTzrSQ==” crossorigin=“anonymous” referrerpolicy=“no-referrer”\>\</script\>

{% end\_require\_js %}

’

and this is in the modules js

gsap.registerPlugin(Flip);

…

const state = Flip.getState(activeItem);  
Flip.from(state, {  
duration: 0.5s,  
absolute: true,  
});

…

---

<div class="post-metadata">

**Author:** ![BarryGrennan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/barrygrennan/32/97794_2.png) [@BarryGrennan](https://community.hubspot.com/u/BarryGrennan)\
**Post date:** [March 25, 2023, 8:25pm UTC](https://community.hubspot.com/t/using-external-cdns-to-import-script-into-module/78018/2 "2023-03-25T20:25:17Z")

</div>

You’re using require\_js correctly. If you view page source you’ll see it there in the footer. Your issue is that by putting the rest of the code in the module js it’s being executed before your libraries are loaded, check your console you’ll see it says gsap is not defined.

Put it all in the require\_js and you should be good. The gsap not defined error goes away.

* * *

 ![profile2022a.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/7273a34ccfe3489fceebc8a36eca751481b59531.jpeg)

**Barry Grennan**

[Freelance HubSpot CMS Developer](https://www.seoanseo.ca?utm_source=HubSpotCommunity)

[Website](https://www.seoanseo.ca?utm_source=HubSpotCommunity) | [Contact](https://www.seoanseo.ca/#contact?utm_source=HubSpotCommunity) | [LinkedIn](https://www.linkedin.com/in/barrygrennan)

---

<div class="post-metadata">

**Author:** ![AKoprivec](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@AKoprivec](https://community.hubspot.com/u/AKoprivec)\
**Post date:** [March 26, 2023, 6:23am UTC](https://community.hubspot.com/t/using-external-cdns-to-import-script-into-module/78018/3 "2023-03-26T06:23:21Z")

</div>

Aa thank you that fixes it yes. Is there any other way to do this, it doesn’t seem like good practice ti have a lot of js code inside the html file or is this the only way to solve this in hubspot
