[HTML/JavaScript] How to load or preload images on a site faster. via /r/learnprogramming


[HTML/JavaScript] How to load or preload images on a site faster.

I created a plugin for a site I use in order to display images in page as opposed to opening them in a new tab.

Basic set up is that I use the DOM to get images, add it to an array, set them, and display them when needed.

It works pretty well, but it sometimes takes 2 to 4 seconds to load an image, and I'd rather it be a 1 second load at most.

I tried loading all images to the current pages html and then hiding them, and then revealing them when needed. This approach helped a lot, but its still a little too slow for my liking.

Is there any thing else I can do to load images faster?

Here's the preLoad function I use for getting and setting images.

Submitted July 10, 2017 at 06:22PM by RatherPleasent
via reddit http://ift.tt/2uKf1KT

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s