Fork me on GitHub
Ziad Salah10:08:14

Hi everyone, I'm trying to embed an external script via something like:

[:script {:type "text/javascript" :src ""}]
When I click around to get to the page where I have that embedded, I can see the script tag in the DOM when I inspect the html, however that script never gets loaded in the network tab. Am I missing something here? I thought the above might be enough but perhaps there's something I should be doing differently to embed an external script?


Does the JS console show any related errors?

Ziad Salah11:08:21

There are no errors anywhere, but most importantly the network tab never shows the script loading.


IIRC, the network tab won't show it if its loading is prevented by the CORS policy. But it should've been logged in the JS console.


Ah, it's just not supported in React:

👍 1

There are NPM libraries to circumvent that though.

Ziad Salah11:08:47

Thank you very much for that link, I guess I'll try some of the proposed solutions there.

Ziad Salah16:08:22

For anyone curious (or from the future searching this channel for a similar issue), the solution we went for is to utilise reagent's form-3 components and the component-did-mount and component-will-unmount life cycle events to manually create the script element as described in the updated accepted answer in the stack overflow linked by @U2FRKM4TW (thanks again btw 🙂)

👍 4