| 1 |
/** |
| 2 |
* Optimole Image Optimizer - Main Entry Point |
| 3 |
* |
| 4 |
* Detects images with data-opt-id attribute that are above the fold |
| 5 |
* and logs them along with the current device type |
| 6 |
* |
| 7 |
* This file imports and orchestrates all the modular components: |
| 8 |
* - Logger utilities |
| 9 |
* - Storage management |
| 10 |
* - Device detection |
| 11 |
* - API communication |
| 12 |
* - DOM utilities |
| 13 |
* - Background image handling |
| 14 |
* - LCP detection |
| 15 |
* - Image detection and analysis |
| 16 |
*/ |
| 17 |
|
| 18 |
// Import all modules |
| 19 |
import { optmlMain } from './modules/main.js'; |
| 20 |
|
| 21 |
(function() { |
| 22 |
'use strict'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Initialize the image detection process |
| 26 |
*/ |
| 27 |
function initializeOptimizer() { |
| 28 |
if (optmlMain && optmlMain.runProfiling) { |
| 29 |
optmlMain.runProfiling(); |
| 30 |
} else { |
| 31 |
console.error('[Optimole] Main module not available'); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
// Ensure the DOM is loaded before running detection |
| 36 |
if (document.readyState === 'loading') { |
| 37 |
document.addEventListener('DOMContentLoaded', initializeOptimizer); |
| 38 |
} else { |
| 39 |
initializeOptimizer(); |
| 40 |
} |
| 41 |
})(); |
| 42 |
|