Why Should You Compress Images for Your Website?
- The average online shopper expects your pages to load in two seconds or less.
- After three seconds, up to 40% of website visitors will abandon your site.
- When waiting for a webpage to load, 14% of shoppers will begin shopping at another site, and 23% will stop shopping or walk away from their computer.
- The average impact of a 1-second delay meant a 7% reduction in conversions
Heavy images can account for the bulk of website weight. Detailed, high resolution images might be overkill for your website, especially if you find yourself resizing images for different screen sizes. Compressing images ensures that you are not carrying any unnecessary weight that will slow your website down – and that your users will still get a top notch user experience.
Filestack allows you to easily compress images. (Note, Filestack also provides API wrappers for image compression if you prefer a specific programming language).
- Sign up for a free account to get your API key.
- Include the Filestack library in your code:
- Find the URL of the jpeg or png you are compressing. (Files that are not jpeg or png will be returned without compression). Using Filestack, you have two options here.
- You can use any externally hosted public file. Simply use the image url. For example, take this glorious but massive 4097×2848 rhinoceros picture: https://fossilrimblog.files.wordpress.com/2014/06/rs11711__do37002.jpg
- You can use Filestack’s file uploading API to upload the image. When uploading with Filestack, you are returned a CDN URL that you can use to transform and deliver images through Filestack’s integrated CDN. This is advantageous, as files delivered through CDNs are cached with regional servers worldwide, so your images tend to load a lot faster and use less bandwidth for globally distributed viewers. Your Filestack CDN URL should look something like: https://cdn.filestackcontent.com/iEoTBdtQRajSJ1eO7FU8
- Compress the image using the
compresstransformation parameter. For an external file, you can use the code:
https://process.filestackapi.com / [YOUR API KEY] / compress / [IMAGE URL]
https://process.filestackapi.com/AhTgLagciQByzXpFGR10Az/compress/https://fossilrimblog.files.wordpress.com/2014/06/rs11711__do37002.jpgIf the file has already been uploaded using the Filestack API you can pass in the file handle and simply use the formula:
https://cdn.filestackcontent.com / compress / [filelink]Just as with the external URL, this will result in an identical compressed image. For example:
https://cdn.filestackcontent.com/compress/iEoTBdtQRajSJ1eO7FU8One thing to note is that by default, Filestack strips metadata from images on compression to reduce its size. However, you can tell the API to keep metadata by passing compress=metadata:true with your compression URI.For example:
Additional Image Optimization
Image compression is just a first step in optimizing images for high performance. Filestack offers a plethora of other tools to manage images, including an integrated content delivery network (CDN), responsive imaging functionality, and transformations to crop, resize, and otherwise edit images. Sign up now to get started optimizing your images.
We’re eager to see how this works for you! Please leave questions and comments below in the comments, or reach out directly to firstname.lastname@example.org.
Read More →