Skip to content

What is best place to put externally hosted javascript for a specific page? #2001

Closed Answered by kiliman
bjorntheart asked this question in Q&A
Discussion options

You must be logged in to vote

That's a perfectly acceptable solution. If you want to make it more generic, take a look at remix-utils <ExternalScripts/> component.

It allows you to add the external scripts to the handle export in your route.

// routes/checkout.tsx
export const handle = {
  scripts: () => [{ src: 'https://cdn.paddle.com/paddle/paddle.js' }]
}

Then your root layout renders the <ExternalScripts/> component.

https://github.com/sergiodxa/remix-utils#externalscripts

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@bjorntheart
Comment options

@yannick-softwerft
Comment options

@MEBonham
Comment options

@kiliman
Comment options

@kiliman
Comment options

Answer selected by bjorntheart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants