Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

Created Unassigned: Unnecessary $().SPServices.SPGetCurrentSite() [10255]

$
0
0
Today while working on performance for an active project, I noticed an unexpected blocking call being made by SPServices. I tracked it down to the logic that determines the URL of the current site. It appears that a call is made using $().SPServices.SPGetCurrentSite() even if a webURL param is specified in the options.

#Current Block
```
var thisSite = $().SPServices.SPGetCurrentSite();
if (opt.webURL.charAt(opt.webURL.length - 1) === SLASH) {
ajaxURL = opt.webURL + ajaxURL;
} else if (opt.webURL.length > 0) {
ajaxURL = opt.webURL + SLASH + ajaxURL;
} else {
ajaxURL = thisSite + ((thisSite.charAt(thisSite.length - 1) === SLASH) ? ajaxURL : (SLASH + ajaxURL));
}

```
#Suggested Fix
```
if (opt.webURL.charAt(opt.webURL.length - 1) === SLASH) {
ajaxURL = opt.webURL + ajaxURL;
} else if (opt.webURL.length > 0) {
ajaxURL = opt.webURL + SLASH + ajaxURL;
} else {
var thisSite = $().SPServices.SPGetCurrentSite();
ajaxURL = thisSite + ((thisSite.charAt(thisSite.length - 1) === SLASH) ? ajaxURL : (SLASH + ajaxURL));
}

```

I've made the change locally in my code and the issue appears to be resolved.

Thanks a lot for all the hard work. Love the library!

--Scott

Viewing all articles
Browse latest Browse all 6517

Trending Articles