I am trying to create two script editor web parts in SharePoint 2013. Both of them should retrieve items from distinct lists and display them on a page.

In the script editors I am using JavaScript as follows:

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

<script type="text/javascript">


My trouble is, if there is only one web part, I see the items of a list. But if I have another script editor like the script above, I get JavaScript errors and no items are displayed. It seems that I cannot reference sp.runtime.js and sp.js twice.

What is the best practice to use sp.runtime.js and sp.js in web parts?

1 Answer 1


There is no need to reference SharePoint JavaScript libraries explicitly, especially in web parts. Consider the SP.SOD.executeFunc method to load on demand scripts instead, for example:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function(){

   var context = SP.ClientContext.get_current();
   //your code goes here...

  • I have done as Vandim has mentioned. when I save my page one of the webparts is not showing up. And when I try to debug it, I get the error SCRIPT5022: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. sp.js?rev=PaF2ZrI2GlTO1B5ru0gYug%3D%3D, line 2 character 219913but. Please help me on this one. Many thanks Commented Jun 11, 2014 at 17:55
  • Ok I have got the issue fixed. I am so embarrassed, that is not even funny. But out of respect for Vadim and our members this is what was wrong. I had copied and pasted the first webpart's javascript to the other webpart. Then made the necessary changes to retrieve the other list. Well I kinda skipped changing the listname... ooops. So when it was looking for items in the other list it threw the error. Will never happen again. Thank you. Commented Jun 11, 2014 at 19:50

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.