Enable sp.js in Publishing Pages in SharePoint 2013/2016

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:

Add a script editor web part in your web part page in SharePoint and 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.

You may like following SharePoint tutorials:

This tutorial, we learned how to enable sp.js in Publishing Pages in SharePoint 2013/2016.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>