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:
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.