javascript before code retreat