Add a JavaScript Link to a Content Editor Web Part
A SharePoint Online tutorial by Peter Kalmström
In
an earlier demo
Peter Kalmström, CEO and Systems Designer of kalmstrom.com
Business Solutions, showed how to add a link in the Content
Editor web part to a text file containing the CSS code in
the Site Assets library, instead of adding the CSS code
to the HTML source of the web part.
This "link to CSS" method is quicker to change, as you don't
have to open the page in edit mode and then open the source.
Instead you can make the change directly in the CSS file.
You can do the same thing with a JavaScript code. Instead
of adding the JavaScript snippet to the HTML source of the
Content Editor web part, as described in the
previous demo,
you can enter the code in a .js or .htm file and save it
to the Site Assets. Then you can just add a link in the
Content Editor web part.
Add the JavaScript snippet to a .js or .htm file
and upload it to the Site Assets library.
Add a Content Editor web part to the page.
Edit the web part and type the path to the JavaScript
file.