=== Easy Optimizer – Page Cache, Lazy Load, Unused CSS, Delay JS & Core Web Vitals ===
Contributors: easywpstuff
Tags: performance, cache, lazy load, core web vitals, speed
Requires at least: 6.4
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 2.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

All-in-one WordPress speed optimization — page cache, lazy load, delay JS, remove unused CSS, LCP preload, font optimization and more. Ace PageSpeed Insights.

== Description ==

Easy Optimizer is a free, all-in-one performance plugin that covers every PageSpeed Insights recommendation in a single install. No bloat, no upsells — just fast pages and green Core Web Vitals scores.

**What it does:**

**Page Cache** — Static HTML caching with Apache .htaccess or PHP fallback. Separate caches for mobile and desktop. Cache preloading via sitemap. Browser caching and Gzip compression out of the box. Sub-millisecond TTFB on cache hits.

**Remove Unused CSS** — Strips CSS rules your page doesn't need. Generates slim "used CSS" per page type and injects it inline. Original stylesheets are deferred or async-loaded. Directly addresses the "Reduce unused CSS" PageSpeed audit.

**Delay JavaScript** — Postpones JS execution until user interaction (mouse, keyboard, touch, scroll). Eliminates render-blocking JavaScript and reduces Total Blocking Time. Configurable exclusions for critical scripts.

**Lazy Load Images, Videos & Iframes** — Defers offscreen images, videos, background images and iframes. Supports WebP, AVIF and SVG. Skips above-the-fold images automatically. Adds missing width and height attributes to prevent CLS.

**LCP Preload** — Automatically detects and preloads the Largest Contentful Paint image on every page. Uses a lightweight PerformanceObserver beacon — zero configuration needed. Adds `fetchpriority="high"` and a `<link rel="preload">` hint.

**Instant Page Load** — Prefetches or prerenders links on hover using the Speculation Rules API. Pages load instantly when clicked. Configurable throttle and concurrency limits protect shared hosting.

**Font Optimization** — Adds `font-display: swap` to all font-face declarations including Google Fonts. Optional lazy-loading of font stylesheets to eliminate render-blocking fonts.

**Image CDN** — Rewrites image URLs to ShortPixel CDN for automatic WebP/AVIF conversion and compression. No API key needed for basic usage.

**Bloat Removal** — 15 toggles to remove WordPress bloat: emojis, embeds, XML-RPC, jQuery Migrate, WP version meta, RSD/WLW links, shortlinks, RSS feeds, self-pingbacks, REST API for logged-out users, Heartbeat, WooCommerce cart fragments, Application Passwords, Dashicons for guests, and Block Library CSS.

**Database Cleanup** — Clean post revisions, auto-drafts, trashed posts, spam comments, trashed comments, expired transients and optimize tables. Schedule automatic cleanup daily, weekly or monthly. Snapshot and restore support for safe cleanup.

**Cloudflare Integration** — Automatic edge cache purge when your page cache clears. Supports both tag-based and full zone purge.

**Hosting Integrations** — Auto-purges server cache on Kinsta, WPEngine, SiteGround, Cloudways, GridPane, RunCloud, SpinupWP, Rocket.net and WordPress.com.

**Accessibility Fixes** — Fix missing form labels, empty link text, button labels, viewport scaling, ARIA roles, iframe titles, progress bar labels and tabindex issues.

**SEO Fixes** — Make all links crawlable and auto-generate missing image alt attributes.

= PageSpeed Insights Recommendations Covered =

* Eliminate render-blocking resources (Delay JS, Unused CSS)
* Reduce unused JavaScript (Delay JS)
* Remove unused CSS (Used CSS generation)
* Ensure text remains visible during webfont load (font-display: swap)
* Defer offscreen images (Lazy Load)
* Properly size images (Add missing dimensions, Image CDN)
* Serve images in next-gen formats (ShortPixel CDN — WebP/AVIF)
* Preload Largest Contentful Paint image (LCP Preload)
* Reduce initial server response time (Page Cache)
* Enable text compression (Gzip)
* Serve static assets with efficient cache policy (Browser Caching)
* Avoid enormous network payloads (Unused CSS, Lazy Load)
* Minimize main-thread work (Delay JS)
* Image elements do not have explicit width and height (Add Dimensions)

= Compatibility =

* **WordPress:** 6.4 and above
* **PHP:** 7.4 and above
* **Hosting:** Works on all hosts. Auto-integrates with Kinsta, WPEngine, SiteGround, Cloudways, GridPane, RunCloud, SpinupWP, Rocket.net, WordPress.com
* **WooCommerce:** Fully compatible. Automatically excludes cart, checkout and my-account from cache. Excludes cart fragment cookies.
* **Page Builders:** Elementor, Beaver Builder, Divi, Gutenberg — all compatible
* **CDN:** Cloudflare integration built in. Works with any pull CDN.

== External Services ==

This plugin optionally rewrites image URLs to ShortPixel's CDN to serve optimized images:

* Service: ShortPixel CDN (https://cdn.shortpixel.ai/)
* What it does: When "Image CDN" is enabled in plugin settings, image URLs on your site are rewritten so that visitors' browsers request images from ShortPixel's CDN. This enables ShortPixel to serve optimized, next-gen formats like WebP/AVIF where supported.
* What data is sent: Only the image URL requested by the visitor's browser. No additional site data or personal user data is sent by the plugin.
* Links: [ShortPixel Privacy Policy](https://shortpixel.com/privacy) | [ShortPixel Terms of Service](https://shortpixel.com/terms-of-service)

== Frequently Asked Questions ==

= Will this plugin conflict with other caching plugins? =
Yes — you should disable other caching plugins (WP Rocket, W3 Total Cache, LiteSpeed Cache, etc.) before enabling Easy Optimizer's page cache. The optimization features (lazy load, delay JS, unused CSS) can coexist with other caching plugins if you only disable our cache module.

= Is it safe for WooCommerce? =
Yes. Cart, checkout and account pages are excluded from caching automatically. WooCommerce session cookies bypass the cache. Cart fragments can be optionally disabled via the Bloat tab.

= Does it work with Cloudflare? =
Yes. Enter your API token and Zone ID in the Cloudflare tab. When Easy Optimizer clears its page cache, Cloudflare's edge cache is purged automatically.

= What does "Remove Unused CSS" do exactly? =
It parses each page's HTML, identifies which CSS selectors are actually used, and generates a slim stylesheet with only the needed rules. Original stylesheets are deferred so they don't block rendering. The result is a significant reduction in CSS payload and faster First Contentful Paint.

= Will Delay JavaScript break my site? =
Most sites work perfectly. If you notice broken functionality, add the problematic script to the exclusion list. jQuery is excluded by default. You can also exclude specific URLs from delay entirely.

= How does LCP Preload work? =
On the first visit to a page type, a lightweight JavaScript beacon detects the LCP image using the browser's PerformanceObserver API. On subsequent visits, the plugin injects a `<link rel="preload">` hint and marks the image with `fetchpriority="high"` so it loads as fast as possible.

= Does it support multisite? =
The plugin works on individual sites within a multisite network. Network-wide activation has not been extensively tested yet.

= Is Easy Optimizer better than WP Rocket? =
For users who want powerful optimization without paying $59/year, yes. Easy Optimizer provides page caching, unused CSS removal, delay JS, lazy loading, LCP preload, font optimization, accessibility fixes, SEO fixes and more — all completely free. WP Rocket charges for features that Easy Optimizer includes at no cost. Easy Optimizer also offers unique features like accessibility fixes, SEO fixes, and Speculation Rules API prerendering that WP Rocket does not have.

= Can I use this with Cloudflare? =
Yes. Easy Optimizer has built-in Cloudflare integration. Enter your API token and Zone ID in the Cloudflare tab. When Easy Optimizer clears its page cache, Cloudflare's edge cache is purged automatically — either by tag or full zone purge.

= Will this improve my Google ranking? =
Faster sites rank better. Google uses Core Web Vitals (LCP, CLS, INP) as ranking signals. Easy Optimizer directly addresses all three: LCP Preload improves Largest Contentful Paint, lazy loading and add-missing-dimensions fixes Cumulative Layout Shift, and Delay JavaScript reduces Interaction to Next Paint. Many users report significant PageSpeed score improvements after activating Easy Optimizer.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/easy-optimizer`, or install through the WordPress plugin screen.
2. Activate the plugin.
3. Navigate to Easy Optimizer in your admin menu and configure settings.
4. Enable the features you need and save.

== Screenshots ==

1. Dashboard overview with module status and cache statistics.
2. Cache settings with preload controls.
3. Optimization settings — Delay JS, Unused CSS, Lazy Load.
4. Bloat removal toggles.
5. Database cleanup with snapshot support.

== Privacy ==

Easy Optimizer includes an optional, anonymous diagnostic data sharing feature to help improve compatibility and performance. **This feature is disabled by default** and only activates after explicit opt-in via an admin notice.

**Data collected after opt-in:**

* Plugin version, WordPress version, PHP version
* Active theme name, site locale, multisite status
* Which plugin features are enabled (e.g. cache on/off, lazy load on/off)

**Never collected:** email addresses, IP addresses, site content, usernames, passwords, or any personally identifiable information.

Data is sent once weekly to fluxpress.io over an encrypted HTTPS connection. You can opt out at any time from the plugin settings. All data is deleted when the plugin is uninstalled.

== Changelog ==


= 2.0.0 =
Major release — complete rewrite of the plugin architecture and admin interface.

* New: Full page caching with htaccess, PHP and drop-in modes
* New: Cache preloading via sitemap URL collection
* New: Remove Unused CSS with per-page-type caching
* New: Delay JavaScript execution until user interaction
* New: LCP auto-detection and preload hint injection
* New: Instant page load via Speculation Rules API (prefetch + prerender)
* New: Font optimization with display:swap and lazy-load fonts
* New: Database cleanup with scheduled runs and snapshot/restore
* New: Cloudflare integration with auto-purge
* New: Hosting integrations for 9 managed hosts
* New: Accessibility fixes (8 toggles)
* New: SEO fixes (crawlable links, image alts)
* New: 15 bloat removal toggles including Block Library CSS
* New: React-powered admin dashboard
* New: REST API settings save (sub-second, no page reload)
* New: Single-row settings storage (80 options collapsed to 1)
* New: Background job queue for reliable cache preloading
* New: Browser caching and Gzip compression via .htaccess
* New: Add missing image width/height attributes
* New: WooCommerce, Elementor and page builder compatibility
* Improved: Complete code audit and cleanup for WordPress.org standards

= 1.1 =
* Initial release on WordPress.org.
* Lazy load images, videos, iframes and background images.
* Image CDN via ShortPixel.
* Instant page preloading.

== Upgrade Notice ==

= 2.0.0 =
Major update with page caching, delay JS, unused CSS removal, LCP preload and 25+ new features. All existing settings are preserved during upgrade.
