0

I was wondering how i would go about implementing JS into my SharePoint online master page. Is the best way to have a separate file with JS functions that is stored in the site contents and then referenced by the Masterpage somehow? if so how would i go about referencing it. And if not how else could I go about doing this?

1
  • I assume you're talking straight classic experience? There are no master pages with the new Modern experience Jul 9, 2019 at 16:48

1 Answer 1

4

The best and simple way is to create a JS folder in your Style Library under Site Contents in the current site then reference it into your masterpage like this : <script src="https://tenant/yoursite/Style Library/yourProject/js/yourcustomscript.js"> and you can also make modification directly on your file in SharePoint Online and see results instantly.

2
  • Awesome thanks! and I know that there are a lot of sharepoint snippets that are wrapped in a comment that will still get run by the server... Does this line need to be in one of those? for example "<!--SPM:...-->"? or would the reference line be written without this sharepoint comment?
    – MikeDurso
    Jul 9, 2019 at 17:13
  • 1
    You can add it directly without "<!--SPM:...-->" Jul 9, 2019 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.