Fix repainting issue, externalized inline JavaScript