Skip to content

DeploySlim: Optimize Website Speed & SEO with GitHub Actions

Mike Gotfryd edited this page Apr 12, 2025 · 1 revision

DeploySlim Wiki

Optimizing Website Speed & SEO with Automated Compression in 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.

Why Website Compression Matters for SEO and Developers

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.

Getting Started: Simple Integration

Adding DeploySlim to your GitHub Actions workflow is straightforward. Follow these steps:

  1. Locate your workflow file: This is typically found in your repository under .github/workflows/ (e.g., deploy.yml).

  2. Add the DeploySlim step: Insert the following snippet into your workflow's steps section, 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.

  3. Commit and push your changes: Your workflow will now automatically compress your assets during the deployment process.

Configuration Options (Inputs in with block)

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

How DeploySlim Works: Under the Hood

  1. Directory Traversal: The action starts by examining the directory specified by the directory input.
  2. Content-Type Detection: For each file within the specified directory (and its subdirectories), DeploySlim attempts to determine its MIME content type.
  3. 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.
  4. Algorithm Application: Based on the algorithms input, DeploySlim applies the specified compression algorithms (Brotli and/or Gzip) to the eligible files.
  5. Level Configuration: The brotli-level and gzip-level inputs control the compression strength for each algorithm. Higher levels generally result in smaller files but may increase processing time.
  6. Output Files: The compressed files are created alongside the original files with the .br or .gz extension (e.g., style.css becomes style.css.br and style.css.gz). Your deployment process should be configured to serve these compressed versions with the appropriate Content-Encoding headers.

Best Practices for Deployment

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.

Troubleshooting and Support

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.

Contributing

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.

Show Your Support

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! 💙