# optimole-wp/4.2.11/assets/js/optimizer.js

Optimole – Optimize Images | Convert WebP &amp; AVIF | CDN &amp; Lazy Load | Image Optimization, version 4.2.11. 42 lines.

- Page: https://pluginprobe.com/plugins/optimole-wp/4.2.11/code/assets/js/optimizer.js
- Raw: https://pluginprobe.com/plugins/optimole-wp/4.2.11/raw/assets/js/optimizer.js
- Modified: 2025-10-09T13:04:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/optimole-wp/4.2.11/code/assets/js/optimizer.js#L10-L20`.

```javascript
/**
 * Optimole Image Optimizer - Main Entry Point
 * 
 * Detects images with data-opt-id attribute that are above the fold
 * and logs them along with the current device type
 * 
 * This file imports and orchestrates all the modular components:
 * - Logger utilities
 * - Storage management  
 * - Device detection
 * - API communication
 * - DOM utilities
 * - Background image handling
 * - LCP detection
 * - Image detection and analysis
 */

// Import all modules
import { optmlMain } from './modules/main.js';

(function() {
  'use strict';

  /**
   * Initialize the image detection process
   */
  function initializeOptimizer() {
    if (optmlMain && optmlMain.runProfiling) {
      optmlMain.runProfiling();
    } else {
      console.error('[Optimole] Main module not available');
    }
  }

  // Ensure the DOM is loaded before running detection
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initializeOptimizer);
  } else {
    initializeOptimizer();
  }
})();

```
