What we've lost
Some of the most useful web parts – the content editor web part and the script editor web part – do not have equivalents in the modern experience out-of-the-box. Additionally, by default, the ability to use scripting in modern pages is deactivated.
This removes some functions which many used before in SharePoint such as the ability to save a site, list or library as a template, access to the solution gallery, theme gallery, etc.
Custom scripts and Master pages
While you can reactivate custom scripts for SharePoint sites, you have to be a SharePoint administrator to be able to do it. The screen captures show site, list and library settings before and after activating custom scripts.
In the classic experience we also had access to the Master pages which enabled us to make modifications that would be applied across an entire site collection.
They were also easy to copy to other site collections to reuse.
The modern script editor web part
Roll your own or ask us
The source code is free to download and compile, but you will need to install several programs such as nodeJS, gulp, etc. to be able to create the SPFx package to install.
If you can’t install these prerequisites or don’t have the time or inclination to spend trying to learn how to compile the web part, just get in touch and we will be happy to send you a pre-compiled version of the web part from the latest version of the PnP source code.
Style and function everywhere
While the modern script editor web part is a great replacement for its classic counterparts, it would be impractical as a substitute for site wide modifications we made previously with the master pages.
For this reason, we have created the custom JS/CSS injector extension for SharePoint online.
We have found this so useful, we have decided to make it free to download – just follow the link above and grab a copy.
A word of warning
CSS selectors depend on tag names, id’s and classes to be applied. If it’s your own HTML code you are adding to SharePoint that shouldn’t be a problem, but if you want to change the style of DOM elements generated by SharePoint itself, Microsoft may decide to change the underlying HTML without notice and your custom CSS may stop working.
It might also have been Voltaire, but I’m sure he would have said it with a French accent 😄
The SharePoint REST API allows us to interact with sites, lists, libraries and the data and files they contain and much more besides. We cannot be held responsible for any loss of data caused by your own code, but if you need help to achieve your goals safely, we can help.
Before using either the Modern Script Editor web part or our custom CSS/JS injector extension, we recommend you test your styling and code in a development environment. You can get a free developer tenant from Microsoft here.