WP Manifestindependent plugin directory
manifest / performance / working-with-js-css-html-minify

Working with JS CSS HTML Minify

in plugin wordpress semplice per minificazione di js cs e html

by Alfonso Vertucci - Working with Web · github.com/alfonsovertu/working-with-js-css-html-minify · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/alfonsovertu/working-with-js-css-html-minify/archive/refs/heads/main.zip

Working with JS CSS HTML Minify is a WordPress plugin that bundles the matthiasmullie/minify library to optimise CSS, JavaScript, and HTML without external dependencies. It is built to meet the guidelines of the WordPress Plugin Directory and works on PHP 7.4 and 8.0+ with WordPress 6.0 or later.

Features

  • Granular toggles to enable CSS, JS, and HTML minification individually.
  • Optional caching of generated HTML pages to serve fully rendered responses instantly.
  • Smart cache stored in wp-content/cache/ww-minify/ with automated cleanup tools.
  • Automatically maintains cache-specific .htaccess/web.config directives for long-lived CSS and JS assets when supported.
  • Configurable cache TTL to control how long optimised assets remain stored.
  • Automatically mirrors already minified files into the cache so long-lived headers always apply.
  • Gorgeous WordPress admin page featuring animated toggles and live cache counters.
  • Optional toggle to move async/defer scripts to the footer when it's safe, helping browsers paint sooner on modern themes.
  • Experimental non-blocking delivery mode for aggregated CSS that pairs a preload hint with a media-swapper so themes can opt out of render-blocking styles when compatible.
  • Experimental toggle to cache compatible remote CSS and JavaScript locally so you can add cache headers to third-party assets when it is safe to do so.
  • Automatic DNS-prefetch and preconnect hints for external hosts discovered inside your CSS, reducing connection time for fonts and CDNs.
  • Detects local font directories referenced in your CSS and provisions cache headers for them so PageSpeed no longer complains about missing TTL directives.
  • Bundled translations (English and Italian) and ready for community contributions.
  • Safe fallbacks when a file cannot be minified so your site never breaks.
  • Remote assets are skipped by default to keep third-party scripts (such as Font Awesome kits) functional. You can enable the experimental toggle or use the ww_minify_allow_remote_asset filter to opt in on a per-request basis.

Directory Structure

working-with-js-css-html-minify/
├── assets/
│   └── css/
│       └── admin.css
├── includes/
│   ├── class-ww-minify-admin.php
│   ├── class-ww-minify-assets.php
│   └── class-ww-minify-plugin.php
├── languages/
│   ├── working-with-js-css-html-minify-it_IT.po
│   └── working-with-js-css-html-minify.pot
├── lib/
│   ├── autoload.php
│   └── matthiasmullie/
│       ├── minify/
│       │   ├── LICENSE
│       │   └── src/
│       │       ├── CSS.php
│       │       ├── Exception.php
│       │       ├── Exceptions/
│       │       │   ├── BasicException.php
│       │       │   ├── FileImportException.php
│       │       │   ├── IOException.php
│       │       │   └── PatternMatchException.php
│       │       ├── JS.php
│       │       └── Minify.php
│       └── path-converter/
│           ├── LICENSE
│           └── src/
│               ├── Converter.php
│               ├── ConverterInterface.php
│               └── NoConverter.php
├── readme.txt
├── README.md
└── working-with-js-css-html-minify.php

Installation

  1. Clone or download this repository into your WordPress wp-content/plugins/ directory.
  2. Activate Working with JS CSS HTML Minify from the Plugins screen.
  3. Visit Settings → Working with Minify to toggle minification for CSS, JS, and HTML.
  4. Use the built-in Clear Cache button to regenerate minified files if needed.

Development

  • The plugin relies on the included autoloader (lib/autoload.php) to load the Matthias Mullie minifier classes and the path converter dependency.
  • Code is written following WordPress coding standards and is fully translation-ready.
  • Translations live in the languages folder. Only .po and .pot files are shipped as per request.
  • Remote font mirroring is opt-in via the ww_minify_mirror_remote_fonts filter. Per-font overrides are available with ww_minify_mirror_remote_font, and the maximum mirrored payload size can be tuned through ww_minify_remote_font_max_size.
  • The ww_minify_enable_non_blocking_css filter toggles the preload + swap delivery per request, while ww_minify_non_blocking_css_markup lets developers customise the generated markup when edge cases demand alternate handling.

Testing

  • php tests/test-remote-fonts.php

Manual QA

Remote font mirroring

  1. Enable Cache remote CSS and JavaScript inside the plugin settings.
  2. Add a small mu-plugin or theme snippet that returns true on the ww_minify_mirror_remote_fonts filter (and optionally fine-tune ww_minify_mirror_remote_font).
  3. Visit a page that enqueues a remote stylesheet referencing web fonts (e.g. Google Fonts) and ensure copies of the font files appear under wp-content/cache/ww-minify/.
  4. Reload the page and confirm the fonts render as expected while being served from the local cache without CORS warnings.

Non-blocking CSS delivery

  1. Enable Minify CSS files, Aggregate minified CSS & JS into a single file, and Serve aggregated CSS with a non-blocking preload swap on the settings screen, then clear any page caches.
  2. Load a representative front-end page and verify that the combined stylesheet renders correctly without flashes of unstyled content or missing fonts.
  3. Inspect the HTML output to confirm the aggregated stylesheet prints a <link rel="preload" as="style"> element followed by a print-swap <link rel="stylesheet" media="print" onload="..."> and a `