=== Optimazz – Website Optimization and Speedup ===
Contributors: shiponkarmakar
Tags: performance, cache, optimization, lazy load, webp
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Website optimization and speedup — page caching, JavaScript delay/defer, CSS optimization, lazy-load, WebP, font and database optimization.

== Description ==

Optimazz is an all-in-one performance suite that applies the optimizations with the biggest impact on Core Web Vitals — automatically and safely. Every module is opt-in and reversible, and Optimazz never overwrites another caching plugin's files.

**Modules included:**

* **Page Cache** — serve static HTML instead of running PHP on every request, with smart exclusions (logged-in users, carts, query strings), automatic purging on content changes, and a cron-based cache preloader so visitors never hit a cold page.
* **JavaScript** — defer scripts and delay them until the first user interaction to cut Total Blocking Time, with an exclusion list.
* **CSS** — minify, combine, and load CSS asynchronously to remove render-blocking stylesheets.
* **Image Optimization** — lazy-load images and iframes, add missing dimensions to prevent layout shift, generate and serve WebP/AVIF, bulk-compress your existing library, convert opaque PNGs to JPEG, and replace YouTube embeds with a click-to-load preview.
* **Fonts** — add `font-display: swap`, preconnect to font hosts, and preload font files.
* **Database** — clean revisions, auto-drafts, trashed posts, spam/trashed comments and expired transients, optimize tables, and schedule automatic cleanups.
* **Heartbeat** — reduce or disable the WordPress Heartbeat API per context to lower server load.
* **Tweaks** — disable emojis, embeds, dashicons, query strings, XML-RPC and pingbacks, and add DNS-prefetch / preconnect hints.
* **CDN** — rewrite static asset URLs to your CDN hostname.

A live performance score on the dashboard shows which optimizations are active and your biggest remaining win.

== Installation ==

1. Upload the `optimazz` folder to `/wp-content/plugins/`, or install it from the Plugins screen.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Open **Optimazz** in the admin menu and enable the modules you want.

== Build process and source code ==

The admin interface is a React application. The human-readable source lives in the `src/` directory shipped inside the plugin (`src/index.js` and `src/index.scss`), and the compiled, minified output lives in `build/`.

To regenerate the compiled files from source:

1. Install dependencies: `npm install`
2. Build: `npm run build`

This uses the official `@wordpress/scripts` (webpack) toolchain — no custom or hidden build configuration. All source and build tooling are included in the plugin; nothing is obfuscated.

== Frequently Asked Questions ==

= Does Optimazz work alongside another caching plugin? =

Optimazz will not overwrite another caching plugin's `advanced-cache.php` drop-in. To use Optimazz page caching, deactivate any other page-caching plugin first. The other (non-caching) modules work alongside most plugins.

= Will page caching work on my host? =

Page caching needs `WP_CACHE` to be defined, which Optimazz adds to `wp-config.php` automatically. If `wp-config.php` is not writable, Optimazz shows a notice with the line to add manually.

= Is it safe to delay JavaScript? =

Delay-until-interaction is the biggest speed win but can affect scripts that must run before interaction. Start with "Delay" on and "Delay all" off, then add any problematic script keywords to the exclusion list.

= Does converting PNG to JPEG lose my originals? =

Only opaque PNGs are converted, the original is optionally backed up to `uploads/optimazz-backup`, and the conversion is rolled back if anything fails.

= Does the plugin phone home or collect data? =

No. Optimazz does not track users, register accounts, or send any of your site's or visitors' data to Optimazz servers. See the "External services" section for the only optional third-party hints the plugin can add.

= Why does the plugin add inline &lt;script&gt; and &lt;style&gt; tags to my pages? =

Those small inline fragments (the delay-JavaScript loader, critical/async CSS, the lazy-load helper and LCP preload hints) are the actual optimization output that Optimazz writes into your front-end HTML. They are the product of the plugin's work, not the plugin's own asset loading — a delay-until-interaction loader cannot be enqueued as an external file. The admin interface and all of the plugin's own assets are loaded normally through the WordPress enqueue functions.

== External services ==

Optimazz does not require any external service to function, and it works entirely on your own server by default. Two optional, admin-controlled features can reference third-party hosts:

1. **Google Fonts optimization (Fonts module).** If — and only if — your theme or another plugin already loads Google Fonts, and you enable the Fonts module, Optimazz adds `preconnect` resource hints to `fonts.googleapis.com` and `fonts.gstatic.com` and can add `display=swap` to the existing font URL. Optimazz does not add Google Fonts to a site that isn't already using them, and it does not send any personal or site data — a `preconnect` is only a browser hint to open a connection earlier. The fonts themselves are requested by the visitor's browser from Google, exactly as they were before the plugin, under Google's terms: https://policies.google.com/terms and privacy policy: https://policies.google.com/privacy

2. **CDN rewriting (CDN module).** If you enable the CDN module and enter a CDN hostname, Optimazz rewrites the URLs of your own static assets (CSS, JS, images) to that hostname so visitors' browsers load them from your CDN. The CDN is a service you choose and configure; Optimazz sends no data to it itself and is not affiliated with any CDN provider. Consult your chosen CDN's own terms and privacy policy.

Both features are off by default and take effect only after you explicitly enable them.

== Screenshots ==

1. Dashboard — live performance score, cache statistics, quick actions, and per-module on/off switches.
2. Page Cache — serve static HTML instead of running PHP, with separate mobile caching.
3. File Optimization — defer and delay JavaScript, and minify, combine and async-load CSS.
4. Media — lazy-load images and iframes, add missing dimensions, and convert to WebP/AVIF.
5. Fonts — font-display swap, preconnect to font hosts, and preload font files.
6. Preload — warm the cache automatically so visitors never hit a cold page.
7. Advanced Rules — fine-tune caching with URL, cookie, and user-agent exclusions.
8. Database — clean revisions, drafts, spam, and transients, and optimize tables.
9. Heartbeat — reduce or disable the WordPress Heartbeat API to lower server load.
10. Tweaks — disable emojis, embeds, query strings, XML-RPC, and other front-end bloat.
11. CDN — rewrite static asset URLs to your CDN hostname.
12. Tools — import, export, and reset your configuration.

== Changelog ==

= 1.0.1 =
* Subdirectory-install-safe URL-to-path mapping for CSS/media optimization.
* Simplified the WP_CACHE handling in wp-config.php to a single WP_Filesystem edit.
* Included the React admin source (src/) and documented the build steps.

= 1.0.0 =
* Initial release: page cache + preloader, JavaScript defer/delay, CSS minify/combine/async, image optimization (lazy-load, dimensions, WebP/AVIF, bulk compression, PNG→JPEG, YouTube facade), fonts, database cleanup, heartbeat control, tweaks, and CDN — with a React admin dashboard.

== Upgrade Notice ==

= 1.0.1 =
Compatibility and code-quality improvements for the plugin directory review.

= 1.0.0 =
Initial release.
