javascript - How to optimize the ajax requests in Jquery? -


i building mobile app using jquery mobile, jquery , php back-end. problem in pages sending , receiving multiple ajax requests visibly slowing down performance , causes memory leaks leads crashing of app in low network connections

what possible ways of optimizing ajax requests?

note:- sending ajax requests periodically(like once in second) ajax sent based on events

first off, correctly written ajax code not leak memory. so, if have leak, caused incorrectly written code, not using ajax.

then, there number of optimizations can consider.

  1. combine multiple requests server 1 larger request. saves roundtrips server, saves bandwidth, saves battery , increases performance.

  2. don't poll every second. smarter how poll server.

  3. lengthen polling interval vary based on activity, switch "long polling" or switch websocket can server push no polling.

  4. analyze causing excessive memory consumption , fix bugs or redesign curtail that. there no reason lots of ajax calls should "leak" memory. chew battery life, need not leak memory if coded correctly.

oh, , don't hesitate pull high scale social web apps exist, open debugger, switch network tab , study heck out of doing. may learn high scale apps have solved issue.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -