Improving load times with JS event capturing