fix performance and new mobile menu
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
989d7f0b98
commit
6904171303
4 files changed
+436
-142
No files matched your search
+52
-3
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
// Constantes de versão para cache busting
|
||||
define('THEME_VERSION', '1.0.1');
|
||||
define('THEME_VERSION', '1.0.5');
|
||||
|
||||
/**
|
||||
* Theme setup
|
||||
@@ -38,10 +38,12 @@ add_action('after_setup_theme', 'martinsevieira_setup');
|
||||
function martinsevieira_scripts() {
|
||||
// Styles
|
||||
wp_enqueue_style('martinsevieira-style', get_stylesheet_uri(), array(), THEME_VERSION);
|
||||
wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css', array(), '6.4.0');
|
||||
wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css', array(), '6.4.0', 'all');
|
||||
wp_style_add_data('font-awesome', 'display', 'swap');
|
||||
|
||||
// Scripts
|
||||
// Scripts com defer para melhor performance
|
||||
wp_enqueue_script('martinsevieira-script', get_template_directory_uri() . '/js/main.js', array(), THEME_VERSION, true);
|
||||
wp_script_add_data('martinsevieira-script', 'defer', true);
|
||||
|
||||
// Localizar script para AJAX
|
||||
wp_localize_script('martinsevieira-script', 'ajaxData', array(
|
||||
@@ -51,6 +53,53 @@ function martinsevieira_scripts() {
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'martinsevieira_scripts');
|
||||
|
||||
/**
|
||||
* Adicionar atributos async/defer aos scripts
|
||||
*/
|
||||
function add_defer_attribute($tag, $handle) {
|
||||
if ('martinsevieira-script' === $handle) {
|
||||
return str_replace(' src', ' defer src', $tag);
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
add_filter('script_loader_tag', 'add_defer_attribute', 10, 2);
|
||||
|
||||
/**
|
||||
* Otimizar carregamento de fontes
|
||||
*/
|
||||
function add_font_preconnect() {
|
||||
echo '<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin>';
|
||||
echo '<link rel="dns-prefetch" href="https://cdnjs.cloudflare.com">';
|
||||
}
|
||||
add_action('wp_head', 'add_font_preconnect', 1);
|
||||
|
||||
/**
|
||||
* Remover jQuery Migrate para melhor performance
|
||||
*/
|
||||
function remove_jquery_migrate($scripts) {
|
||||
if (!is_admin() && isset($scripts->registered['jquery'])) {
|
||||
$script = $scripts->registered['jquery'];
|
||||
if ($script->deps) {
|
||||
$script->deps = array_diff($script->deps, array('jquery-migrate'));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action('wp_default_scripts', 'remove_jquery_migrate');
|
||||
|
||||
/**
|
||||
* Desabilitar emojis do WordPress para melhor performance
|
||||
*/
|
||||
function disable_emojis() {
|
||||
remove_action('wp_head', 'print_emoji_detection_script', 7);
|
||||
remove_action('admin_print_scripts', 'print_emoji_detection_script');
|
||||
remove_action('wp_print_styles', 'print_emoji_styles');
|
||||
remove_action('admin_print_styles', 'print_emoji_styles');
|
||||
remove_filter('the_content_feed', 'wp_staticize_emoji');
|
||||
remove_filter('comment_text_rss', 'wp_staticize_emoji');
|
||||
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
|
||||
}
|
||||
add_action('init', 'disable_emojis');
|
||||
|
||||
/**
|
||||
* Register widget areas
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user