Improved (less naive) JS check for possible data loss