Best way to add a script to a single page

Davs Howard asked on November 9, 2015 11:40

What's the best practice to add a script to just ONE page?

I know I can create an ad-hoc template and then add a HTML head webpart, or write some .NET code in the header, but I was hoping for a more elegant and scalable solution.

Cheers

Recent Answers


David te Kloese answered on November 9, 2015 12:01

Hi,

you could use the 'HTML head webpart' visible condition to only show based on some term. Could be on aliaspath but hope you have a more future-proof way of identifying that one page.

Do you have one page that needs an extra script? Or do you have x-pages that all need a different script?

Greets,

David

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on November 9, 2015 13:38

In addition to what David suggested, you can also use the javascript webpart OR us the page template's HEAD property (not recommended because it's too hidden). I'm partial to the javascript webpart because it's smart enough to not execute the js while you're in the Admin interface.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.