This SharePoint tutorial, we will discuss how to enable sp.js in Publishing Pages in SharePoint 2013/2016.
By default, sp.js is not visible in publishing pages in SharePoint.
As the SharePoint uses minimal download strategy it prevents the page to have sp.js when published but the point to note is when you open your ribbon bar (edit or unpublished state) sp.js script gets loaded in your page.
Note: SharePoint loads scripts on Demand
So to solve this we can do like this:
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
Where sharePointReady is a method which will be executed after sp.js is loaded.
You may like following SharePoint tutorials:
- The SPListItem provided is not compatible with a Publishing Page error in SharePoint 2010/2013
- All about Publishing Infrastructure Feature in SharePoint 2013/2016/Online
- SharePoint 2013 Redirect user to custom PageNotFoundError page
- Create custom master page using Design Manager in SharePoint Online
- Activate SharePoint Server Publishing Feature programmatically using CSOM
- Cross site publishing in SharePoint 2013
- Enable Save Site as Template option in Publishing Site in SharePoint Online using PowerShell
- How to add custom ribbon action on list/libraries in SharePoint
This tutorial, we learned how to enable sp.js in Publishing Pages in SharePoint 2013/2016.
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.