I am developing a SP 2013 app and making frequent asynchronous calls via SP.RequestExecutor.js using the REST API. Every time I need a function call I use:

jQuery.getScript(scriptbase + "SP.RequestExecutor.js", myFunction);

I use Visual Studio 2013. After every SP.RequestExecutor call on the Solution Explorer I see a new SP.RequestExecutor.js attached with a ?_=XXXXXXXXXX number appended and it stays there until I stop debugging (see the image attached)

These SP.RequestExecutor files remain until I stop debugging

Is that normal? I also checked the memory usage of the browser on Task Manager and it looks like it is growing slightly after every call, and not sure if this is normal either.

Any ideas?

Edit: Here is some additional info, in case someone tries to help: I am using cross-site collection calls, that's my app is on one site and the lists that the data is retrieved on another but they all live in the same domain. The syntax of my REST call is something like this: appWebUrl/_api/SP.AppContextSite(@t)/web?@t='targetUrl'

  • I don't know if this is normal, or what the consequences are, but I added a copy of the Sp.RequestExecutor.js file in my app, so I just call that instead. Perhaps that would lower the memory usage for your app? – wjervis May 30 '14 at 13:53
  • Hmm I would not recommend that. If MS changes something in the RequestExecutor.js, your copy will not have the changes and your code might break. – Vardhaman Deshpande May 30 '14 at 15:33

The reason why you are seeing multiple SP.RequestExecutor.js files is that jQuery.getScript forces a new version of the file to be loaded every time it is called. So even if the file is loaded in your browser cache, getScript downloads a fresh copy.

I have blogged about this issue and a workaround for it here:

Include Caching in jQuery getScript

Basically you create a wrapper on top of jQuery.ajax with the cache option enabled:

jQuery.getCachedScript = function(url,callback){

            dataType: "script",
            cache: true,
            url: url,

jQuery.getCachedScript(scriptbase + "SP.RequestExecutor.js", myFunction);
  • Hi Vardhaman and thanks for the answer. I did try your code, and it did remove the number after the SP.RequestExecutor.js but it still loads the file and keeps it, which I am assuming, makes it use more memory after every call. I forgot to mention that I am deferring the 'myFunction' function. Do you think this could be the reason of the script being loaded over and over again? – user27227 May 30 '14 at 18:57
  • It will load the js file but it will not get a new copy each time from the server. It will load the js from the browser cache. If you observe the time it takes to load now, it will be far less than before. Also, deferring your function should not impact the loading of the script. – Vardhaman Deshpande May 30 '14 at 19:30
  • That makes sense, and it does load quite faster now. Unfortunately it didn't solve the problem with its consumption of memory. I'm sort of restricted to using IE; what method would you suggest using in order to find out what is consuming all that memory? – user27227 May 30 '14 at 20:13
  • Why not just load the file once and then call all the dependent functions inside your myFunction? – Vardhaman Deshpande May 30 '14 at 20:20
  • We are migrating a program from MS Access to Sharepoint. The program was written 10+ years ago and was not designed to be scalable. We chose to use SP lists and some have 300K rows so when I need data I execute an asynchronous call and retrieve it. There are over a dozen lists so go figure. Thanks for your help, it did speed up my code. I would vote your answer up but don't have enough reputation points. – user27227 May 31 '14 at 23:32

Use this function that allows fetching a cached script:

jQuery.cachedScript = function( url, options ) {

  // Allow user to set any option except for dataType, cache, and url
  options = $.extend( options || {}, {
    dataType: "script",
    cache: true,
    url: url

  // Use $.ajax() since it is more flexible than $.getScript
  // Return the jqXHR object so we can chain callbacks
  return jQuery.ajax( options );

// Usage
$.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {
  console.log( textStatus );

Source: https://api.jquery.com/jquery.getscript/#entry-examples

It's better than Vardhaman's snippet because his custom function doesn't return anything, while the example on jQuery's documentation page returns the jqXHR object that can be used for chaining, for example.

  • Can you post the code or example from the link which you have mentioned. Also a brief description on code will help readers to solve their problem. – Asad Refai Jul 21 '15 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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