SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to use the SharePoint Javascript Object Model from a "plain" html page (ie, not an .aspx application page etc.) Is this even possible? If so, what scripts should I reference? I've added the following:

  <script type="text/ecmascript" src="/_layouts/SP.js" />
  <script type="text/ecmascript" src="/_layouts/SP.Core.js" />
  <script type="text/ecmascript" src="/_layouts/SP.Debug.js" />
  <script type="text/ecmascript" src="/_layouts/SP.Runtime.Debug.js" />

But when the page loads, I get a 'Type is not defined' error in SP.js and SP.Core.js. Note this is from within the SP site, so this isn't a cross-domain issue.

share|improve this question
Where have you hosted the html file? Under \\-<hive>-\Layouts ? If it's just uploaded to a doc library, try using full path of the site e.g. – sumitkm Oct 21 '11 at 8:18
up vote 4 down vote accepted

The SharePoint JavaScript client object model only works on pages that are a part of the SharePoint framework (i.e. in Web Parts, Application Pages, etc.). This tutorial makes mention of that:

share|improve this answer
You could, however, write a custom REST or AJAX web service that does the calls for you and then you could access those from your JavaScript. – John Chapman Nov 6 '11 at 1:08
I actually got it 'almost working', but SP.js definitely depends on some markup and other scripts only found in application pages. REST and Ajax against the built-in listdata.svc, etc. is what I landed on, though I'm not sure I'll be able to get at everything I would have liked (like SPWeb.Navigation). – Daniel Nov 7 '11 at 2:34

This is what I used to fix this problem:

<SharePoint:ScriptLink Name="MicrosoftAjax.js" runat="server" Defer="False" Localizable="false"/>
<SharePoint:ScriptLink Name="SP.core.js" runat="server" Defer="False" Localizable="false"/>
<SharePoint:ScriptLink Name="SP.js" runat="server" Defer="True" Localizable="false"/>

I added the above ScriptLinks in this order, and defered both the MicrosoftAjax.js and SP.Core.js includes, and delayed the SP.js. The SP.js file has dependencies in the preceding includes that requires it to be delayed.

share|improve this answer
this would not work on a plain html page, just a .aspx – Daniel Mar 27 '14 at 19:54
<SharePoint:ScriptLink Name="SP.js" runat="server" OnDemand="true" Localizable="false" />

will do the work.

share|improve this answer

You are missing init.js.

Add it just like the rest of the scripts you have referenced and you should stop getting the dependency errors.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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