This might be a very noob question, but when do you actually use SP.js? In my SharePoint site I am using ajax queries with the REST api like this: http://dev.spdev.local/sites/mysite/_api/web/lists/getbytitle('Random List')/items

Is SP.js just for apps that run in iFrames? Or are people using it on regular SharePoint webpages.

2 Answers 2


Sp.js is a JavaScript library which you should use if you want to use SharePoint client object model in JavaScript. See this link for all methods and properties available in the library. http://msdn.microsoft.com/en-us/library/office/jj245759(v=office.15).aspx . There is no restrictions like it should be used only in apps or iframe etc.

  • When I type new SP.ClientContext() into my browser's console I get back "Object doesn't support this action". Is there some kind of setup involved before using it?
    – matt
    Sep 30, 2014 at 21:00
  • Follow this link to see basic examples of using sp.js msdn.microsoft.com/en-us/library/office/…
    – Unnie
    Sep 30, 2014 at 21:21
  • You want to use var myContext = SP.ClientContext.get_current() or var myContext = new SP.ClientContext('yourFullSiteUrl') if you're trying to access a client context.
    – John-M
    Oct 1, 2014 at 2:32

This JavaScript object library reference contains information that you can use to build custom sites, farm solutions, and apps for SharePoint. JavaScript in SharePoint 2013 is derived from the .NET server programming model, and the programming capabilities defined here reflect those found in the original .NET server source.

http://msdn.microsoft.com/en-us/library/office/jj193034(v=office.15).aspx http://msdn.microsoft.com/en-us/library/office/jj246996(v=office.15).aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.