Images are usually the heaviest part of any website. On an average page they account for more than half of the total content weight, which directly affects loading speed, data usage on mobile devices and search engine rankings. The good news is that image size can almost always be reduced dramatically without visitors noticing any difference in quality. The key is understanding how compression works and which format to use for which type of content.
Why image size matters so much
When we talk about image optimization, it is not just about aesthetics or tidy code. Image weight has measurable consequences on several levels:
- Loading speed: large images increase the time until the first meaningful render and hurt metrics such as Largest Contentful Paint.
- SEO: Google uses speed and Core Web Vitals as a ranking factor, so slow pages lose positions.
- User experience: a visitor on a slower mobile connection leaves a page that takes too long to load.
- Costs: smaller images mean lower bandwidth usage and lower hosting costs.
The goal is not to reduce quality blindly, but to remove surplus data that the human eye does not register anyway.
Understanding lossless and lossy compression
There are two basic approaches to compression, and the difference between them is the essence of the whole topic.
Lossless compression
With this type of compression, the image is made smaller by removing redundant information, but every pixel can be perfectly reconstructed. The result is identical to the original. A reduction of twenty to forty percent is typical, depending on the content. This is ideal for logos, illustrations and graphics where every detail matters.
Lossy compression
Here, data that the human eye barely notices, such as fine differences in shades, is permanently discarded. With careful tuning, an image can be seventy or eighty percent smaller without a visible drop in quality. “Without losing quality” in practice means without visible loss, which is perfectly sufficient for photos on the web.
Choosing the right image format
The biggest mistake we see is using the wrong format for a particular type of image. The format determines how efficiently the data can be packed.
If you are thinking about a new or better website for your company, see how we approach website development for clients in Sarajevo and across Bosnia and Herzegovina.
| Format | Best for | Note |
|---|---|---|
| JPEG | Photos with many colors | Universal, good lossy compression |
| PNG | Graphics, logos, transparency | Large for photos, use sparingly |
| WebP | Almost all types of images | 25-35 percent smaller than JPEG at the same quality |
| AVIF | Photos and complex images | Best compression, somewhat slower encoding |
| SVG | Icons, vector illustrations | Scalable, tiny, resolution-independent |
For modern projects, we recommend WebP as the base format for photos, with AVIF as an advanced option and JPEG or PNG as a fallback for older browsers. This approach covers every visitor without compromise.
Practical steps to reduce file size
Optimization is not a single action but a series of steps that build on one another. Here is the order that gives the best results.
- Adjust the dimensions: never put a 4000-pixel image into a space that is 800 pixels wide. Scaling the actual dimensions down to what is really displayed often halves the file size before any compression.
- Choose the format: convert photos to WebP or AVIF, and vectors to SVG.
- Set the quality level: for most photos, a quality of 75 to 85 percent gives an excellent balance. The difference compared to 100 percent is practically invisible, and the savings are huge.
- Remove metadata: EXIF data, geolocation and camera information needlessly increase the file size and can be a privacy risk.
- Use responsive images: the
srcsetattribute lets every device get an image of the appropriate size instead of one huge image for all.
Tools and automation
Optimizing every image by hand is not sustainable as a website grows. A smarter approach is to build optimization into the content publishing process itself.
- Tools for individual images: Squoosh, TinyPNG and ImageOptim are excellent for quick manual tasks and for checking results.
- Libraries and build tools: sharp for Node.js, or plugins for tools such as Vite and Webpack, generate optimized versions automatically during the build.
- Image delivery services: CDNs can convert and resize images on the fly based on the visitor’s device, which eliminates the need for manual work.
- CMS plugins: on WordPress, plugins automatically create WebP variants and compress every new image on upload.
Once optimization is set up as an automatic step, the team entering content does not have to think about technical details. That is exactly the approach we apply in our website development projects, where performance has to be built in from the ground up.
Lazy loading and delivering the right size
Reducing the size of an individual image is only half the story. The other half is when and how that image is loaded at all. The loading="lazy" attribute delays loading images that are outside the visible part of the screen until the user scrolls to them. This makes the initial page load significantly faster, especially on long pages with a lot of visual content.
Combined with responsive images, this means a phone on a slower connection never downloads the large version intended for a desktop screen. Every visitor gets exactly as much data as they need, no more and no less.
Common mistakes to avoid
During website audits, we regularly come across the same oversights that slow a site down unnecessarily:
- Using the PNG format for photos, which creates files several times larger than necessary.
- Uploading images in the camera’s full resolution directly to the page without any resizing.
- Over-compression that creates visible artifacts and blotches, which spoils the impression of professionalism.
- Forgetting the
altattribute, which matters for both accessibility and SEO.
Image optimization is one of the most cost-effective ways to improve performance: a relatively small effort brings a large and measurable benefit. If you want your website to be fast, rank well and be pleasant to use, this is a great place to start. If you need an expert assessment of your website’s current state, feel free to contact us and we will help you identify the biggest opportunities to speed it up.

