Unless you're an assassin on a government contract, you need to be on Google if you run a business. This doesn't mean just indexing your website: it means getting on the first page of search results. An important factor affecting the search engine position is how fast your website is loading. In other words, the better it's optimized, the higher it displays on Google.
One of the basic optimization tips is compressing website images with third-party tools, a thing developers often do in their pipelines with Gulp/Grunt/npm scripts before the deployment. We're excited to announce that Buddy now has a dedicated action allowing you to compress images without scripts and external libraries.
Here's an example pipeline for a website running on WordPress:
- Run tests
- Compress images
- Upload files to server (FTP/SFTP/S3 etc.)
- Invalidate cache
In the action you can set the following details:
- The path to the images (Buddy will look for images recurrently in every subfolder)
- Output directory for compressed images in the pipeline filesystem
- Level of compression: low, medium, or high
- Type of iamges to process:
Once you configure the action and execute the pipeline, Buddy will compress all selected file types and produce them in the output directory.
Buddy will retain file naming and folder structure in the output directory. This means that the relative path to the compressed image will be the same as to the image before the compression
At the moment, the files are indicated by their extension:
svg. In the future, we are going to add detection based on the MIME type.
If you want to deploy the application together with compressed images, you need to add two deployment actions:
- The first should deploy application files without images (use the file ignore option to specify the extensions, e.g.
- The second should deploy the compressed images from the folder that you defined as the output directory in the compress action
Both actions should deploy to the same path on the remote server to make sure the application is deployed in full.
The action only compresses files that have changed since the last deployment. This allows deployment actions to use changeset mechanisms (i.e. only deploy changed files, not all images at once), which significantly improves the speed of upload.
The action is based on a dedicated application which is available in our public repository on GitHub on MIT License: https://github.com/buddy-works/imgcmp. You can also download it as a Docker image or an npm package
If you tips or suggestions on improving the action, feel free to share them in the comments or on our live-chat.
You use lots of tools to get web & app development done. Buddy creates more time in your day by helping you automate those tools.