Reorganizing js, and embedding base64 image