| @@ -355,8 +355,19 @@ | ||
| 355 | 355 | return self::minify_js_string($js, true); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | + * Check if the JS code contains import statements | |
| 360 | + * | |
| 361 | + * @param string $js | |
| 362 | + * @return boolean | |
| 363 | + */ | |
| 364 | + public static function has_js_import_statements($js) { | |
| 365 | + $js = preg_replace('/\/\/.*|\/\*[\s\S]*?\*\//', '', $js); // Remove comments to avoid false positives | |
| 366 | + return 1 === preg_match('/\bimport\b/', $js); | |
| 367 | + } | |
| 368 | + | |
| 369 | + /** | |
| 359 | 370 | * Functions, minify html |
| 360 | 371 | * |
| 361 | 372 | * @param string $html |
| 362 | 373 | * @return string |