-
Notifications
You must be signed in to change notification settings - Fork 0
DeploySlim: Optimize Website Speed & SEO with GitHub Actions
Welcome to the official Wiki for DeploySlim, the free GitHub Action designed to automatically compress your website's assets using Brotli and Gzip, directly within your CI/CD pipeline. This action helps you significantly improve your website's loading speed, enhance user experience, and boost your search engine rankings – all with seamless integration into your existing GitHub workflows.
For SEO:
- Faster Load Times = Higher Rankings: Search engines like Google consider page load speed as a crucial ranking factor. Faster websites generally rank higher.
- Improved User Experience: Quick-loading websites lead to lower bounce rates and higher engagement, which are indirect SEO benefits.
- Mobile-First Indexing: With the increasing importance of mobile, fast loading times on mobile devices are critical for SEO.
For Developers:
- Enhanced Performance: Smaller file sizes mean faster downloads for users, leading to a snappier and more responsive website.
- Reduced Bandwidth Consumption: Compression saves bandwidth for both your hosting provider and your users.
- Simplified Workflow: Automate the compression process within your deployment pipeline, eliminating manual optimization steps.
- Cross-Platform Compatibility: DeploySlim works seamlessly on both Linux and Windows build environments within GitHub Actions.
- Flexibility: Configure compression algorithms and levels to suit your specific needs.
Adding DeploySlim to your GitHub Actions workflow is straightforward. Follow these steps:
-
Locate your workflow file: This is typically found in your repository under
.github/workflows/(e.g.,deploy.yml). -
Add the DeploySlim step: Insert the following snippet into your workflow's
stepssection, usually after your build process and before your deployment step:- name: Compress Assets with DeploySlim uses: CornerstoneCode/DeploySlim@v1 with: directory: './public' # ⚠️ Replace with the path to your built website assets algorithms: 'br,gz' # Optional: Specify compression algorithms (default: br,gz) brotli-level: 9 # Optional: Set Brotli compression level (0-11, default: 6) gzip-level: 7 # Optional: Set Gzip compression level (0-9, default: 6)
Remember to replace
'./public'with the actual path to the directory containing your built website files. -
Commit and push your changes: Your workflow will now automatically compress your assets during the deployment process.
The DeploySlim action can be customized using the following inputs within the with: block of your workflow step:
| Name | Description | Default |
|---|---|---|
directory |
Path to your website's build output directory. DeploySlim will recursively compress compressible files within this directory. | . |
algorithms |
Comma-separated list of compression algorithms to use. Available options: br (Brotli), gz (Gzip). |
br,gz |
brotli-level |
Integer representing the Brotli compression level (0-11). Higher values offer better compression but may take longer. | 6 |
gzip-level |
Integer representing the Gzip compression level (0-9). Higher values offer better compression but may take longer. | 6 |
-
Directory Traversal: The action starts by examining the directory specified by the
directoryinput. - Content-Type Detection: For each file within the specified directory (and its subdirectories), DeploySlim attempts to determine its MIME content type.
-
Smart Compression: Only files with text-based MIME types (e.g.,
text/html,text/css,application/javascript,image/svg+xml,application/json,application/xml,application/wasm) are considered for compression. Binary files like images (except SVG), videos, and audio are typically not compressed. -
Algorithm Application: Based on the
algorithmsinput, DeploySlim applies the specified compression algorithms (Brotli and/or Gzip) to the eligible files. -
Level Configuration: The
brotli-levelandgzip-levelinputs control the compression strength for each algorithm. Higher levels generally result in smaller files but may increase processing time. -
Output Files: The compressed files are created alongside the original files with the
.bror.gzextension (e.g.,style.cssbecomesstyle.css.brandstyle.css.gz). Your deployment process should be configured to serve these compressed versions with the appropriateContent-Encodingheaders.
To fully leverage the benefits of DeploySlim, ensure your deployment process is configured to serve the compressed files with the correct HTTP Content-Encoding headers. Most modern web servers (like Nginx, Apache, and cloud hosting platforms like Netlify, Vercel, AWS S3 with CloudFront) offer mechanisms to handle this.
Example Server Configuration (Conceptual - Consult your server's documentation):
Your server configuration should typically check for the presence of .br or .gz files and serve them with the corresponding Content-Encoding: br or Content-Encoding: gzip header if the client (browser) indicates support for these encodings in its Accept-Encoding request header. If the compressed file doesn't exist or the client doesn't support the encoding, the original uncompressed file should be served.
If you encounter any issues or have questions about using DeploySlim, please:
- Review the README: The main README file in the repository contains the most up-to-date information and examples.
- Check GitHub Issues: Look through the existing issues in the repository to see if your problem has already been reported and potentially resolved.
- Open a New Issue: If you can't find a solution, feel free to open a new issue in the repository, providing as much detail as possible about your problem, workflow configuration, and any error messages.
DeploySlim is an open-source project, and contributions are welcome! If you have suggestions for improvements, bug fixes, or new features, please feel free to:
- Fork the repository.
- Create a new branch for your changes.
- Submit a pull request with a clear description of your changes.
If you find DeploySlim helpful in optimizing your website, please consider leaving a star ⭐ on the repository! Your support helps others discover this action and encourages further development. Thank you! 💙