I'm using a getJSON request to display a random image on hover. My problem is that each image is loading slowly, I believe because the JSON request is happening on each hover. Any suggestions on how I could make this request work quicker? Many thanks :)
$.getJSON('images.json', function(result) {
$('#imagehover').on('mouseenter', function() {
var index = Math.floor(result.url.length * Math.random());
$("#imageresult").html($('<img>', {src: result.url[index]}));
});
});