Neatest (and fast) way to remove top lines from a textarea
问题 I have a webpage that displays last 1000 lines of a logfile then updates via AJAX every x seconds loading new content (if any) and appending to textarea with $('#log').append(new_data) , a sort of tail -f . The problems come up after some time when too many lines are appended and the page becomes slow or unresponsive. So I'd like to limit number of lines to, say, 5000 so it means I should: retrieve new_data calculate overflow = 5000 - lines_ in_new_data - lines_in_textarea if overflow > 0