Malin revidoval tento gist . Přejít na revizi
1 file changed, 63 insertions
elementor-thin.php(vytvořil soubor)
| @@ -0,0 +1,63 @@ | |||
| 1 | + | <?php | |
| 2 | + | // from https://github.com/PieterT2000/elementor-hacks | |
| 3 | + | // Remove unused scripts loaded by Elementor | |
| 4 | + | function wpse_elementor_frontend_scripts() { | |
| 5 | + | // you can change yourself for which pages the conditional logic below accounts | |
| 6 | + | if(is_front_page()) { | |
| 7 | + | // Dequeue and deregister swiper | |
| 8 | + | wp_dequeue_script( 'swiper' ); | |
| 9 | + | wp_deregister_script( 'swiper' ); | |
| 10 | + | ||
| 11 | + | // Dequeue and deregister elementor-dialog | |
| 12 | + | wp_dequeue_script( 'elementor-dialog' ); | |
| 13 | + | wp_deregister_script( 'elementor-dialog' ); | |
| 14 | + | ||
| 15 | + | // Dequeue and deregister elementor-frontend | |
| 16 | + | wp_dequeue_script( 'elementor-frontend' ); | |
| 17 | + | wp_deregister_script( 'elementor-frontend' ); | |
| 18 | + | ||
| 19 | + | // Re-register elementor-frontend without the elementor-dialog/swiper dependency. | |
| 20 | + | $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; | |
| 21 | + | wp_register_script( | |
| 22 | + | 'elementor-frontend', | |
| 23 | + | ELEMENTOR_ASSETS_URL . 'js/frontend' . $suffix . '.js', | |
| 24 | + | [ | |
| 25 | + | 'elementor-frontend-modules', | |
| 26 | + | 'elementor-waypoints' | |
| 27 | + | ], | |
| 28 | + | ELEMENTOR_VERSION, | |
| 29 | + | true | |
| 30 | + | ); | |
| 31 | + | } | |
| 32 | + | } | |
| 33 | + | add_action( 'wp_enqueue_scripts', 'wpse_elementor_frontend_scripts' ); | |
| 34 | + | ||
| 35 | + | // Remove style.css -- Gutenberg | |
| 36 | + | function wps_deregister_styles() { | |
| 37 | + | if ( ! is_admin()) { | |
| 38 | + | wp_dequeue_style( 'wp-block-library' ); | |
| 39 | + | } | |
| 40 | + | } | |
| 41 | + | add_action( 'wp_print_styles', 'wps_deregister_styles', 100 ); | |
| 42 | + | ||
| 43 | + | // Remove WP-embed | |
| 44 | + | function deregister_wpembed(){ | |
| 45 | + | if ( ! is_admin()) { | |
| 46 | + | wp_deregister_script( 'wp-embed' ); | |
| 47 | + | } | |
| 48 | + | } | |
| 49 | + | add_action( 'wp_footer', 'deregister_wpembed' ); | |
| 50 | + | ||
| 51 | + | // Remove JQuery migrate | |
| 52 | + | function remove_jquery_migrate( $scripts ) { | |
| 53 | + | if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) { | |
| 54 | + | $script = $scripts->registered['jquery']; | |
| 55 | + | ||
| 56 | + | if ( $script->deps ) { // Check whether the script has any dependencies | |
| 57 | + | $script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) ); | |
| 58 | + | } | |
| 59 | + | } | |
| 60 | + | } | |
| 61 | + | add_action( 'wp_default_scripts', 'remove_jquery_migrate' ); | |
| 62 | + | ||
| 63 | + | ?> | |
Novější
Starší