If I start writing post in Facebook and then either close or refresh page, Facebook somehow recognizes each of these actions (Reload site vs Leave site).
In javascript there's onbeforeunload
event that gets called when webpage is about to unload, but how does Facebook manage to recognize if page unloads due to browser close or browser refresh function? Event doesn't contain that information afaik.
window.addEventListener('beforeunload', function(e) {
// this is browser refresh or close?
});