0

I am building a javascript plugin that a client will include in his. The plugin will track data user activity like page scroll, button clicks mouse movements etc and then save to web storage. This data then need to be send to a back end server at regular intervals of say 5-10 seconds in json format.

  • If I use a simple ajax for sending data by using setInterval method will that impact user browsing experience.?
  • Will using websockets make more sense in this case or is there any other way?

NOTE: The backend server application is based on Spring MVC and the javascript plugin will push data to server externallly from clients application.

Nikhil Mahajan
  • 523
  • 5
  • 17

1 Answers1

0

If you really wanted minimal impact on the UI thread, you could spawn a WebWorker and do the AJAX requests from there.

Here is a good answer explaining AJAX requests in the context of a WebWorker. Here is another short example of implementing AJAX in a WebWorker.

bitshift
  • 498
  • 2
  • 13