ThemeMagic: Optimize javascript code