In this post we will discuss how to enable sp.js in Publishing Pages in SharePoint 2013. By default sp.js is not visible in publishing pages.
Also check out:
– Delete multiple items in batch using SharePoint 2013 default services
– Change Item Level Permission using SharePoint designer workflow
– Disable default email for approval workflow in SharePoint 2010 designer
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:
1. Add a script editor webpart in your page and in script tags just add the following code snippet:
SP.SOD.executeFunc(‘sp.js’, ‘SP.ClientContext’, sharePointReady);
Where sharePointReady is a method which will be executed after sp.js is loaded.