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.zipWorking 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.configdirectives 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_assetfilter 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
- Clone or download this repository into your WordPress
wp-content/plugins/directory. - Activate Working with JS CSS HTML Minify from the Plugins screen.
- Visit Settings → Working with Minify to toggle minification for CSS, JS, and HTML.
- 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
languagesfolder. Only.poand.potfiles are shipped as per request. - Remote font mirroring is opt-in via the
ww_minify_mirror_remote_fontsfilter. Per-font overrides are available withww_minify_mirror_remote_font, and the maximum mirrored payload size can be tuned throughww_minify_remote_font_max_size. - The
ww_minify_enable_non_blocking_cssfilter toggles the preload + swap delivery per request, whileww_minify_non_blocking_css_markuplets developers customise the generated markup when edge cases demand alternate handling.
Testing
php tests/test-remote-fonts.php
Manual QA
Remote font mirroring
- Enable Cache remote CSS and JavaScript inside the plugin settings.
- Add a small mu-plugin or theme snippet that returns
trueon theww_minify_mirror_remote_fontsfilter (and optionally fine-tuneww_minify_mirror_remote_font). - 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/. - Reload the page and confirm the fonts render as expected while being served from the local cache without CORS warnings.
Non-blocking CSS delivery
- 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.
- Load a representative front-end page and verify that the combined stylesheet renders correctly without flashes of unstyled content or missing fonts.
- 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 `