I added the following code to my asp.net-mvc site.master page with the goal is making sure this image gets loaded upfront and cached (as I use it all over my site):
$(document).ready(function () {
var x = new Image();
x.src = "/content/images/ajax-loader.gif";
I am assuming this code would force a preload and cache of this ajax loading image but when i run a page that references this image, i still see this for a few seconds. Here is an example of a jqgrid loading div
which uses this code for loadtext:
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "View {0} - {1} of {2}",
emptyrecords: "No records to view",
loadtext: "Loading Data ...<img src='/Content/Images/ajax-loader.gif' />",
pgtext : "Page {0} of {1}"
},
before my actual ajax loading image shows like below:
Is there any suggestion for what could be causing this and how to ensure this image is loaded and cached prior to trying to use it? Is my solution actually redownloading the file each time?
What is the best recommendation here for how to achieve my goal?