# 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:** 1\
**Showing post:** 2

<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]]
      })
  },
})

```

---

_[View the full topic](https://forum.8thwall.com/t/how-to-add-cdns/6203)._
