Skip to content

Instantly share code, notes, and snippets.

@metaylimpo
metaylimpo / speedup elementor.php
Last active September 19, 2022 20:24
Speed Up Elementor
<?php
// disable google fonts
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
// add font-display swap to elementor custom fonts
add_filter( 'elementor_pro/custom_fonts/font_display', function( $current_value, $font_family, $data ) {
return 'swap';
// you can also play also with $current_value & $font_family for specific requirments
}, 10, 3 );
@metaylimpo
metaylimpo / .htaccess
Last active June 23, 2022 08:56
Example of wordpress .htaccess file for several optimizations and other things
#DO NOT COPY\PASTE. Take only what you need carefully.
#The following code is just a few **examples** of optimizations that you can do in .htaccess file.
# HTTPS forced
<IfModule mod_rewrite.c>
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
@metaylimpo
metaylimpo / functions.php
Last active February 2, 2022 15:39
Example of wordpress theme function file for several optimizations
/*
DO NOT COPY\PASTE. Take only what you need carefully.
The following code is just a few **examples** of optimizations that you can do in functions.php file.
*/
<?php
// disable google fonts
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
@metaylimpo
metaylimpo / defer example.php
Last active June 8, 2020 23:31
Example how to defer js in Wordpress with function.php file
<?php
if (!is_admin()) {
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
if ( strpos( $tag, "jquery.js" ) ||
strpos( $tag, "leaflet.js") /*||
strpos( $tag, "add any script you want" )*/ ) {
return $tag;
}
return str_replace( ' src', ' defer="defer" src', $tag );