1

What would happen if I have a lot of ajax request, let say 10 jquery ajax request on the $(window).load(function ()) when the website opens??

I am planing to do a lot of ajax request I am just wondering what would happen and would it make my website lagging?

rodolfo navalon
  • 183
  • 1
  • 1
  • 13
  • A lot of queued requests, as most browsers put a limit on the number of concurrent requests to the same server that they will allow – Mark Baker Apr 24 '13 at 22:12
  • http://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser – Ejaz Apr 24 '13 at 22:13
  • It could potentially block code execution in some cases, but typically it's supposed to just continue working while loading them in the background, x requests at a time based on the browser. – Kevin B Apr 24 '13 at 22:13
  • 1
    Wouldn't you just want to use PHP to load them when the page loads? then use AJAX to change them – ntgCleaner Apr 24 '13 at 22:14

1 Answers1

2

No, it wouldn't make the rendering (!) of your page laggy since the requests are executed asynchronously.

However, if the your page depends on the data from the services before displaying anything, then it will probably feel laggy.

Keep in mind that if you do a lot of requests, the browser will start queueing them.

Kenneth
  • 28,294
  • 6
  • 61
  • 84
  • 2
    2 HTTPD requests maximum in *most* newer browsers. Can be circumvented with node.js or leveraging some spiffy nginx modules. – Ohgodwhy Apr 24 '13 at 22:18
  • @Ohgodwhy It is incorrect to say "in most newer browsers". 2 Http request is the RFC rule on the "server side" per hostname. The number of connections per server for browsers is a different story: http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/ – hexalys Apr 25 '13 at 00:20