Trouble arises when trying to load high-resolution images in Chrome on a Windows operating system using JavaScript

Having an issue with a website where I am progressively loading multiple images - starting with a smaller resolution image for faster loading and then ajaxing in a larger image (usually the original size uploaded by the user).

The following code functions as intended. However, when viewed on Chrome for Windows, if the larger image is of very high resolution (e.g., 4400 x 4000), the screen turns white and the image disappears. The white spills out of the container (which has overflow:hidden) and covers the entire screen, with only elements having a higher z-index displaying.

When inspecting the element that appears white, it indicates that it's the element and that the image is loaded correctly - the URL is fine and clicking on the image to open in a new tab works just fine.

Any insights into why this might be happening?

if(href){

   var img = document.createElement('img');
   img.className = 'openLBFullView hidden';
   img.onload = function(){
       loadBiggerImg(this);
   };

   $(img).data('url',$currentImg.data('url'));
   img.src = href;
   img.id = 'my-image';

}

var loadBiggerImg = function(img){
     var originalImg = $('#my-image');

     //append the img to the document
     originalImg.before(img);

     // append original styles and classes to new image
     $(img).attr('style',originalImg.attr('style'));
     $(img).attr('class',originalImg.attr('class'));

     // fix for windows IE adding attributes
     $(img).removeAttr('width').removeAttr('height');

     //fade in new image over the top and remove old one
     $(img).fadeIn(200,function(){
        originalImg.remove();
     });

}

Answer №1

Here is a suggestion for addressing the issue of large images not rendering in Chrome: large images dont render in chrome

While this solution may not necessarily solve your specific problem, you could try using low-resolution JPEGs scaled to high resolution and preloading the larger image. Once the big image is loaded, you can fade out the low-res one and display the high-res version, giving the appearance of a progressive JPEG load. I hope this suggestion is helpful to you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The ongoing challenge with the 'active' class in jQuery

Here is an example of a menu: <ul class="nav nav-list"> @for (int i = 1; i <= pageno; i++) { <li> <a href="~/Insts?page=@i&count=10">@i</a></li> ...

Loop through the items in the List and retrieve various values linked to a dropdown menu for a specific item by utilizing both jquery and SharePoint web services

I am currently working on a project where I have a list and I am using caml query to select an item based on certain criteria. The item has multiple lookup fields, and my goal is to bind them to a dropdown list. However, the code I have written so far only ...

Element eradicated by mysterious force - what is the reason behind this destruction?

I encountered a peculiar issue while working on a JS game demo. For some reason, one of the functions is unexpectedly deleting the container element (even though I didn't intend for it to do so). This function usually creates another element inside th ...

What are the best methods for capturing individual and time-sensitive occurrences within a service?

I am currently working on structuring the events within a service to enable a mechanism for subscribing/unsubscribing listeners when a controller's scope is terminated. Previously, I utilized $rootScope.$on in this manner: if(!$rootScope.$$listeners[& ...

Why does JSON.parse need to be run twice - once for a string and once for an object?

When I send a JSON string via websocket (Socket.io) from a Node.js server to a client's browser, I find that I have to execute the JSON.parse function twice in order to extract an object from the received JSON string. This behavior is confusing to me. ...

Issues with JQuery scroll() / scrollTop() functionality in Internet Explorer and Firefox

Our current script showcases a dotted line starting from the top of the screen leading to an up arrow. The position of the arrow changes based on how far the user has scrolled down the page, allowing them to click on the arrow and scroll back to the top. W ...

Checking with Protractor to see if the modal is displayed

I am currently working on a Protractor test to check if a bootstrap modal window that confirms the deletion of a record is visible at this time. The record that needs to be deleted is displayed in an angular ng-repeat, so I have to trigger the delete butt ...

Ways to display an SVG spinner prior to a substantial UI refresh

I am currently facing an issue with updating 10 apexcharts bar charts simultaneously in a Vue app. When this process occurs, it takes approximately one second to load completely, and during that time, I would like to display an svg spinner. However, the co ...

Breaking the condition within the while loop (Now featuring a code snippet)

Let's clarify the condition in the while loop, which should check if the new challenge number has not been completed yet (as indicated in the challenges.finished array). This means that the same challenge can be displayed multiple times instead of jus ...

Troubleshooting a GreenSock problem related to the z-index

With the help of GreenSock TweenMax, I have successfully achieved the desired animations. However, I am facing an issue where the "flag" that moves out to the right needs to be positioned over the next diamond instead of being underneath it. Interestingly, ...

Creating circular images using ASP.NET

Is it possible to generate rounded images using asp.net? I'm looking for a way to upload any image and have asp.net create a round version of it. My development environment is .Net framework 3.5 with Visual Studio .NET 2008. Thank you in advance! ...

What is the method for connecting a page with a submit button?

<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button> I have a code snippet from bootstrap that creates a button. How can I modify this code to add a link to another HTML file while maintaining data val ...

Navigating the waters of adding a CSS property to a jQuery variable pseudo selector

Is there a way to adjust the top position for $myClass both before and after? I attempted to do so with the following code: var $myClass = $(".myclass"); $myClass.filter(":before,:after").css("top",-23); ...

Receiving an unknown result from the bodyParser function

Currently, I am in the early stages of learning nodejs + express + handlebars and facing some challenges with my post request. The issue lies in extracting data for "province and municipality" from req.body.province and req.body.municipality, which is not ...

Error: Unable to execute this.context.router.push due to it not being a function

I recently encountered an issue where the browser console displayed the same message as the post title. The problem occurred when trying to navigate to a profile page after clicking a dropdown button. contextTypes: { router: React.PropTypes.func }, _h ...

"Utilizing jQuery to enable smooth scrolling of entire windows with every twist of the mouse, similar to the

Does anyone have tips on how to achieve a scrolling effect that covers 100% of the window, similar to what is seen on this website? My website currently has vertical scrolling, with each div set to 100% width and height. I have implemented an anchor syste ...

Struggling to apply size in percentage to several images used as a background

Displaying two background images with different positioning: html { background: top left no-repeat url(http://wallpapers.pupazzo.org/animals/Peek-a-Boo_Red_Fox_Kit.jpg), top right no-repeat url(http://www.dcwild.com/images/Fox-Kit-Rive ...

Module request: How can I save the gathered cookies as a variable?

library: https://www.npmjs.com/package/request I am attempting to simultaneously log in with multiple accounts on a website. To manage each session effectively, I plan to create an object where I will store the cookies associated with each account. Now, ...

An asynchronous operation fails to execute

Exploring a controller content within the context of a nodejs app: var express = require('express'), directory_router = express.Router(), directory_models = require('./directory_models'); directory_router.get('/list&apo ...

Node.js bypasses unit test validation

As a beginner in BDD with Node.js, I have a controller function defined as follows: var getUser = function(username, done) { console.log('prints'); User.findOne({ 'local.username': username }, function (err, user) { ...