Improve javascript a lot for images