# How to add CDN's?

**URL:** <https://forum.8thwall.com/t/how-to-add-cdns/6203>\
**Category:** Technical Support\
**Tags:** general\
**Created:** [April 25, 2025, 5:37pm UTC](https://forum.8thwall.com/t/how-to-add-cdns/6203 "2025-04-25T17:37:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herman\_Ptacnik](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@Herman\_Ptacnik](https://forum.8thwall.com/u/Herman_Ptacnik)\
**Post date:** [April 25, 2025, 5:37pm UTC](https://forum.8thwall.com/t/how-to-add-cdns/6203/1 "2025-04-25T17:37:14Z")

</div>

How can I add a CDN to my 8th wall project? Normally we just added a script tag in index.html, but I’m not sure if adding one will override something.

What is the recommended way of doing this?

---

<div class="post-metadata">

**Author:** ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)\
**Post date:** [April 29, 2025, 8:09pm UTC](https://forum.8thwall.com/t/how-to-add-cdns/6203/2 "2025-04-29T20:09:55Z")

</div>

Here’s how I would do it in a custom component:

```ts
import * as ecs from '@8thwall/ecs'

ecs.registerComponent({
  name: 'cdn-component',
  schema: {
  },
  schemaDefaults: {
  },
  data: {
  },
  stateMachine: ({world, eid, schemaAttribute, dataAttribute}) => {
    const toLoaded = ecs.defineTrigger()

    ecs.defineState('default')
      .initial()
      .onEnter(() => {
        const tag = document.createElement('script')
        tag.setAttribute('src', 'https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js')
        tag.addEventListener('load', () => {
          toLoaded.trigger()
        })
        document.body.appendChild(tag)
      })
      .onTrigger(toLoaded, 'loaded')

    ecs.defineState('loaded')
      .onEnter(() => {
        // Must ignore the error otherwise it won't build because it doesn't know lodash exists.
        // @ts-ignore
        console.log(`Lodash v${window._.VERSION}`)
        // @ts-ignore
        console.log(_.chunk([1, 2, 3, 4, 5], 2)) // → [[1,2],[3,4],[5]]
      })
  },
})

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/9/9212a857458f1b03a6accb129e0f8cbea408e3e5.png) [@system](https://forum.8thwall.com/u/system)\
**Post date:** [May 3, 2025, 8:10pm UTC](https://forum.8thwall.com/t/how-to-add-cdns/6203/3 "2025-05-03T20:10:54Z")

</div>

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.
