# Performance Optimisation Plugin

A comprehensive WordPress plugin designed to optimize your website's performance by managing cache, optimizing JavaScript and CSS files, and improving image loading with advanced features like lazy loading, preloading, and more.

---

## Features

### Dashboard
- Overview of:
  - Cache status (size and clear cache option).
  - Minified JavaScript and CSS count.
  - WebP and AVIF image optimization status:
    - **WebP**: Completed, Pending, Failed.
    - **AVIF**: Completed, Pending, Failed.
  - Recent activities (e.g., plugin activation, cache clearing logs).

### File Optimization Settings
- Minify JavaScript and CSS.
- Combine CSS and exclude specific files.
- Defer or delay JavaScript loading.
- Minify HTML.
- Remove WooCommerce CSS/JS from non-relevant pages.
- Save settings with a single click.

### Preload Settings
- Enable cache preloading (generate static HTML and GZIP files).
- Add preconnect origins.
- Prefetch DNS domains.
- Preload fonts, CSS files, and specific images.
- Preload feature images for specific post types with configurable exclusions.

### Image Optimization Settings
- Lazy load images with:
  - SVG placeholders for smoother rendering.
  - Exclusion of a specified number of images.
- Convert images to **WebP** or **AVIF** formats.
- Preload images for the front page or feature images by post type.
- Limit preloaded image sizes with exclusions.

### Tools
- Import/export plugin settings.

---

## Installation

### For End Users
1. Clone the repository:
   ```bash
   git clone https://github.com/your-username/performance-optimisation.git
   ```
2. Navigate to the plugin directory:
   ```bash
   cd performance-optimisation
   ```
3. Install Composer dependencies:
   ```bash
   composer install
   ```
4. Install npm dependencies:
   ```bash
   npm install
   ```
5. Build the plugin assets:
   ```bash
   npm run build
   ```
6. Upload the plugin folder to your WordPress site's `wp-content/plugins/` directory or install it through the WordPress admin dashboard.
7. Activate the plugin from the **Plugins** menu in WordPress.

### For Developers
1. Follow the above steps.
2. To start the development environment:
   ```bash
   npm run start
   ```

---

## Usage

1. Navigate to the **Performance Optimisation** menu in the WordPress admin panel.
2. Explore the following sections:
   - **Dashboard** for an overview of optimization status.
   - **File Optimization Settings** for JavaScript, CSS, and HTML optimization.
   - **Preload Settings** to configure caching and preloading options.
   - **Image Optimization Settings** for lazy loading and format conversion.
   - **Tools** for importing/exporting settings.

---

## Dependencies

This plugin utilizes the following libraries:

- [voku/html-min](https://github.com/voku/HtmlMin) - HTML minification.
- [matthiasmullie/minify](https://github.com/matthiasmullie/minify) - JavaScript and CSS minification.
- [@wordpress/scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) - Build tools for modern WordPress development.
- [Font Awesome Free Solid Icons](https://fontawesome.com/v6/icons?o=r&s=solid) and [React FontAwesome](https://github.com/FortAwesome/react-fontawesome) for icons.

---

## Composer Configuration

```json
{
	"name": "nilesh/performance-optimisation",
	"description": "A package for performance optimization, including HTML minification and code minification tools.",
	"license": "GPL-2.0-or-later",
	"authors": [
		{
			"name": "nilesh",
			"email": "nilesh.kanzariya912@gmail.com"
		}
	],
	"require": {
		"voku/html-min": "^4.5",
		"matthiasmullie/minify": "^1.3"
	},
	"extra": {
		"cleanup": {
			"dirs": ["bin", "tests", "docs"],
			"exclude": ["*.md", "*.yml", "*.xml", "tests", "docs"]
		}
	}
}
```

---

## NPM Configuration

```json
{
	"name": "performance-optimisation",
	"version": "1.0.0",
	"description": "Performance optimisation plugin for WordPress",
	"main": "./src/index.js",
	"scripts": {
		"build": "wp-scripts build",
		"start": "wp-scripts start"
	},
	"author": "Nilesh Kanzariya <nilesh.kanzariya912@gmail.com>",
	"license": "GPL-2.0-or-later",
	"devDependencies": {
		"@wordpress/scripts": "^27.9.0"
	},
	"dependencies": {
		"@fortawesome/free-solid-svg-icons": "^6.7.1",
		"@fortawesome/react-fontawesome": "^0.2.2"
	}
}
```

---

## Changelog

### v1.0.0
- Initial release
  - Dashboard overview.
  - Cache management.
  - JavaScript, CSS, and HTML optimization.
  - Image optimization and lazy loading.
  - Preloading for cache, fonts, and images.
  - Import/export tools.

---

## Contributing

Contributions, issues, and feature requests are welcome!  
Feel free to check the [issues page](https://github.com/nilesh-32236/performance-optimisation/issues).

---

## License

This project is licensed under the GPLv2 license. See the LICENSE file for more details.

---

## Author
Created by Nilesh Kanzariya.
