- use a Content Editor Webpart (CEWP)
- edit via the Source Editor button (not Rich Text Editor), and
- add your code within standard
Within the script block just add your normal code, comments, etc. The only issue you’ll have is being able to indent the text and make it look pretty. Tab doesn’t help; you’ll need to use spaces (the horror!).
Don’t use the Rich Text Editor
Important! Always use the Source Editor function to manipulate your code, or any other content within the same CEWP. If you use the Rich Text Editor at any point it will delete all your script.
To link to a separate file:
- add/edit your CEWP to reference the script file: