🎉 RapidLoad 3.0 is released! Follow this guide to migrate to the new version. Read more → 🎉

Minify JS

Minify JS

Minify JS optimizes JavaScript code by removing unnecessary whitespace, comments, and formatting, reducing file size for faster loading. It improves website speed, enhances user experience, and boosts SEO without altering functionality.

Here’s how RapidLoad Minify JS works:

  1. Identifying JavaScript Files:

    • RapidLoad searches your website’s Document Object Model (DOM) for files with the .js extension.
  2. Minifying JavaScript Files:

    • Once identified, RapidLoad proceeds to minify these JavaScript files for optimized performance.
  3. Minifying Inline JavaScript:

    • Inline JavaScript within <script> tags is minified and served in real-time.
  4. Storage of Minified Files:

    • RapidLoad stores minified files at wp-content/cache/rapidload/min-js/{file-name}-{file-content-hash}.min.js.
    • RapidLoad does not save the minified inline JavaScript as a file.
  5. Clearing Minified Files:

    • You can clear the minified JavaScript files by clicking the Clear CSS/JS/Font Optimizations button once you hover over the RapidLoad admin button on the WordPress dashboard bar.
  6. Replacing Original Files:

    • The original JavaScript files are not deleted but are replaced with minified JavaScript files renamed with the Src and version (?ver=xxx) details.
      • Original file: https://demo.rapidload.ai/wp-includes/js/script.js?ver=6.3.2
      • Minified file: https://demo.rapidload.ai/wp-content/cache/rapidload/min-js/script-9a7d09a200c6.min.js
  7. Re-minification on Version Change:

    • RapidLoad will re-minify and serve files if the original files undergo version changes.

Excluding Files from Minify JavaScript Optimization

In some cases, you may want to prevent specific JavaScript files from being minified. RapidLoad allows you to easily exclude files from Minify JavaScript optimization to ensure certain scripts remain untouched and function as intended.

Examples of Valid Exclusions:

  • Third-Party JavaScript: Scripts hosted on external domains (e.g., Google Analytics, chat widgets).
  • Already Minified Files: JavaScript files already optimized with the .min.js extension.
  • Custom Scripts: Files critical to your site’s functionality that may not work well when minified (e.g., specific vendor scripts or custom interactions).

How to Exclude Files from Minify JavaScript in RapidLoad:

  1. Navigate to the Optimize tab in the RapidLoad plugin.
  2. Click on the Customize Settings dropdown.
  3. Find the JavaScript section and locate the Minify JavaScript Exclusions option.
  4. Click the Settings next to it.
  5. Enter the file paths, names, or patterns for scripts you want to exclude from minification.
  6. Click Save Changes to apply your exclusions.

By excluding specific files, you ensure that critical scripts are not unintentionally modified, while still optimizing other JavaScript files for better performance.