simple JS image loader function