Raghavendar Swaminathan

Raghavendar Swaminathan

  • 600
  • 3.3k
  • 80.6k

SPFx Webpart getting loaded with delay

Mar 3 2020 12:17 PM
Hi Team,
 
I am facing some challenges in the loading time of the webpart(15 secs). I was pulling data from the list and binding it to the drop down control in ajax but it has some waiting time since async call is involved.
 
I need a better performance how this can be achieved. can anyone provide insights.
  1. function getPackingSites()  
  2. {  
  3. var packagingSiteUrl = siteAbsUrl + "/_api/web/lists/GetByTitle('"+packingSiteList+"')/Items";  
  4. var packagingSiteOptions ="";  
  5. $.ajax({  
  6. url:packagingSiteUrl,  
  7. method: "Get",  
  8. async: false,  
  9. headers: {  
  10. "accept""application/json;odata=verbose",  
  11. },  
  12. success: function (PackingSiteData) {  
  13. if (PackingSiteData.d.results.length > 0) {  
  14. for (var i = 0; i < PackingSiteData.d.results.length; i++) {  
  15. packagingSiteOptions += "<option value='"+PackingSiteData.d.results[i].ID+"'>"+PackingSiteData.d.results[i].Title+"</option>";  
  16. }  
  17. }  
  18. },  
  19. error: function (x, e) {  
  20. alert(e.message.tostring());  
  21. }  
  22. });  
  23. $("#PackingSiteDropdwn").html(packagingSiteOptions);  
  24.   
  25. var tempLink = '<a id="newformSubmit" class="btn offset" href="'+siteAbsUrl+'/pages/Create.aspx?PackSiteID='+$("#PackingSiteDropdwn").val()+'&Source='+siteAbsUrl+'">Submit</a>';  
  26. $("#newformSubmitSpan").html(tempLink);  
  27. }  
  28. }  

Answers (1)