Reusable javascript code