Wrap up the javascript code as comment of @ashfame