Sharepoint - SP.js file not loaded in a simple JSOM example

Try adding following references to the additional page head of the page

<script type="text/javascript" src="_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="_layouts/15/sp.js"></script>

Then try using following script

jQuery(document).ready(function ()
{
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems);
}); 

function retrieveListItems() {
    alert('Libraries Loaded');
}

I used include all the requires javascripts as per the below sequence and there by I was able to include the SP.js.

<script src="/_layouts/1033/init.js" type="text/javascript"></script>
<script src="/_layouts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/_layouts/sp.core.js" type="text/javascript"></script>
<script src="/_layouts/sp.runtime.js" type="text/javascript"></script>
<script src="/_layouts/sp.js" type="text/javascript"></script>

I have referred this link.

The most important of all is that one should include jquery.min.js and not jquery.js. This is small point which would create havoc in your life.


It could be you're calling retrieveListItems before SP.js has been fully loaded, in which case try:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems);