Here is an example implementation on github, but certainly my organisation will not implement it (straight out of github project), unless Microsoft can push this capability to Sharepoint:
Please see this image for more details, where I am trying to suggest adding a new Web Part for Scripts+CSS:
This capability is available in old Sharepoint Pages, so hopefully it should be easy to push in Modern Pages (which I really like to use).
Thanks for your feedback! Although we appreciate your time and effort to give us this feedback, it’s not something we’re planning to do right now.
Challenge of allowing site owners to embed scripts or CSS is huge security risks which that model enables without centralized coordination/approval at tenant level.
This model was widely adopted in the classic SharePoint from the site owner perspective, but it also caused clear security risks for any tenant where the script embedding was enabled.
SharePoint Framework was designed to address this security concern by only enabling embedding scripts to the modern pages if this is enabled in tenant level by installing a solution which allows that. If this capability is needed – you can absolutely develop your own script embedding web part, but Microsoft is not planning to enable this security issue in modern SharePoint.
We are not also planning to enable embedding CSS styles on a site level without tenant administrative approval. Classically this model was used to change the behavior of out-of-the-box styles. As the UX or html structures should not be considered as an API, we are not looking to enable this model anymore in SharePoint.
We will certainly enable additional options for providing company specific branding or to add widgets on the modern pages, but as we are not planning to provide script edit web part or CSS embedding capabilities, we will be closing this request.
1 commentComments are closed
Gabriel Smoljár commented
WordPress has done this in a nice way. Each block (section or web part in the SharePoint world) has a property called "Custom CSS class". This class is then added to the root element of that block. You can then add a style for that class in the theme's CSS. Something similar in SharePoint would be nice.