If you dont want to use external processing of log messages a simple way is to use the javascript timeout function
setTimeout(function(){ <write to log/db> }, 3000);
where 3000 is the delay in processing the function, this way the current thread does not wait for the completion of the write.