להלן מספר הוראות וקוד שתוכלו להשתמש בו לצורך אופטימיזציה של מהירות האתר שתוכלו לבדוק כאן https://developers.google.com/speed/pagespeed/insights/?hl=en
- התקן תוסף Autoptimize והגדר את האפשרויות הבאות:
- התקן תוסף מטמון של WP Super
- התקן תוסף דחיס תמונות JPEG ו- PNG
- הגדר את האפשרויות שלך כאן '/wp-admin/options-general.php?page=tinify'
- התקן תוסף שבת טבעות
- התקן תוסף השבת אמוג'ים (ידידותי ל- GDPR)
- הוסף את הקוד הבא בקובץ העיצוב הנוכחי שלך ב- WordPress functions.php:123456789101112131415161718192021222324add_filter('autoptimize_html_after_minify', function($content) {$site_url = 'https://YOUR_SITE_LINK_HERE';//do not set slash on the end$content = str_replace("", ' ', $content);$content = str_replace('', ' ', $content);$content = str_replace(" ", ' ', $content);$content = str_replace(' ', ' ', $content);$content = str_replace("rel='stylesheet preload' as='style'", "rel='stylesheet preload'", $content);$content = str_replace('rel="stylesheet preload" as="style"', 'rel="stylesheet preload"', $content);$content = str_replace('@font-face {font-display: swap; ', '@font-face {font-display: swap; font-display: swap;', $content);$content = str_replace('@font-face {font-display: swap; ', '@font-face {font-display: swap; font-display: swap;', $content);$content = str_replace("<img", "<img loading='lazy'", $content);$content = str_replace($site_url . '/wp-includes/js', '/wp-includes/js', $content);$content = str_replace($site_url . '/wp-content/cache/autoptimize', '/wp-content/cache/autoptimize', $content);$content = str_replace($site_url . '/wp-content/themes/', '/wp-content/themes/', $content);$content = str_replace($site_url . '/wp-content/uploads/', '/wp-content/uploads/', $content);$content = str_replace($site_url . '/wp-content/plugins/', '/wp-content/plugins/', $content);return $content;}, 9999, 1);
- כמו כן ניתן לבצע אופטימיזציה jquery.js אשר אינו נכלל ב Autoptimize, אבל בדרך זו לא תמיד עובד, אז בדוק את הפונקציונליות של האתר שלך לאחר הבא:
- בקובץ הנושא הנוכחי של wp באתר שלך functions.php הוסף את הקוד הבא:1234//exlude jquery to print it in the header by file_get_contentsadd_action('wp_enqueue_scripts', function () {wp_deregister_script('jquery');});
- בקובץ הנושא הנוכחי של wp באתר שלך functions.php הוסף קוד הבא לפני :123<script><?php echo file_get_contents(ABSPATH . WPINC . '/js/jquery/jquery.js'); ?></script>
- בקובץ הנושא הנוכחי של wp באתר שלך functions.php הוסף את הקוד הבא:
- להיות זהיר עם jquery.js אופטימיזציה