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 Answer
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.
-
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? Commented Jul 9, 2019 at 17:13
-
1You can add it directly without "<!--SPM:...-->" Commented Jul 9, 2019 at 19:19