Basic opportunities for code optimization by the programmer and the compiler. Program code optimization

Home / Doesn't work

On this site I usually share my experiences, but sometimes I need advice myself. And this short article will be just from this series, since the problem is a little beyond my competence, but it needs to be solved. Therefore, the question is to some extent for the readers. But the fact is that our dear Google told me that this site of mine is not complete and this is slowing down the site.

I'm not a programmer; as they say, I don't speak any languages. But the issue must be resolved, and that is why I raised it here. Of course, although the question is complex, it is no more difficult than understanding what it is and how it helps manage trade.

How to optimize the site code?

I'll try to figure this out on the pages of my blog. Besides, you won’t be able to do everything at once, but you need to have an action plan.

I want to start by explaining where the dog is buried. Probably you, like me, use some kind of content management system for your website: WordPress, Joomla, Drupal or something else. These systems are made by professionals, and there are few errors in them.

But the templates that most of us take from the public domain are prone to errors. , especially free ones, are often made by amateurs, and their creations are not perfect. And it was the kind Google who pointed out the errors in the template to me. What are they?

Google shows separately errors when loading a site from mobile devices and desktops. There is a difference, however. So, what errors or even code flaws are there in my template?

For computers:

1. Should Fix - this is a high level of error!

Use your browser cache!
By specifying the date or expiration date of static resources in the HTTP headers, the browser will load previously retrieved resources from the local disk rather than from the Internet.
Use your browser cache for the following resources:

Http://avatars-fast.yandex.net/get-direct/nubNH6Z6vqKZZtboVlYcQg/y80 (validity period not specified) http://directstat.ru/script (validity period not specified) https://prostolinux.ru/karta- saita/ (validity period not specified) https://prostolinux.ru/prostolinux.png (validity period not specified) (validity period not specified) (validity period not specified) https://prostolinux.ru/wp-content/themes /rockwell_new/rockwell/css/jquery.lightbox-0.5.css (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/css/orange.css (validity period not specified) https ://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/css/superfish.css (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/images/bk_body. jpg (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/images/bk_dotted_vert.gif (validity period not specified) https://prostolinux.ru/wp-content/themes/ rockwell_new/rockwell/images/bk_menu_orange.jpg (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/images/bullet_top.jpg (validity period not specified) https://prostolinux. ru/wp-content/themes/rockwell_new/rockwell/images/ico_date_orange.png (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/images/topmenu_border_orange.jpg (validity period not specified actions) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/js/copy.js (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/js /jquery-1.3.2.min.js (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/js/jquery.form.js (validity period not specified) (not specified validity period) (validity period not specified) https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/style.css (validity period not specified) https://prostolinux.ru/wp-includes/images/ smilies/icon_smile.gif (validity period not specified)

It’s not yet clear to me what the validity period is and where it needs to be indicated. You know?

2. Consider Fixing

Remove rendering-blocking JavaScript and CSS from the top of the page.

Number of blocking scripts per page: 1. Number of blocking CSS resources per page: 4. They slow down the display of content.
All content at the top of the page is displayed only after the following resources have been loaded. Consider delaying the loading of these resources, loading them asynchronously, or embedding their most important components directly into the HTML code.
Remove the JavaScript code that is preventing the display:

Https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/js/jquery-1.3.2.min.js

Optimize your CSS on the following resources:

https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/style.css
https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/css/orange.css
https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/css/jquery.lightbox-0.5.css
https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/css/superfish.css

Here the problem is more clear, but I don’t know how to solve it yet. Uploaded to local server a copy of the site to safely edit the code. Let's train.

3. Minify JavaScript - This is a medium error rate. Fixing the error will speed up the site a little.
JavaScript code compression reduces the amount of data to allow faster loading, processing, and execution.
Minify the JavaScript code in the following resources to reduce their size by 19.4 KB (46%
Reducing https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/js/jquery-1.3.2.min.js will reduce the size by 14 KB (41%
Reducing https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/js/jquery.form.js will reduce the size by 5.4 KB (64%
4. Optimize your images – this is a medium error rate. Fixing the error will speed up the site a little.

The correct format and compression of images can reduce their size.

Optimize the following images to reduce their size by 5 KB (14%
If you losslessly compress an image, it will reduce its size by 2 KB (8%
If you compress the image https://prostolinux.ru/wp-content/themes/rockwell_new/rockwell/images/ico_date_orange.png losslessly, this will reduce its size by 1.7 KB (31%
If you compress the image http://avatars-fast.yandex.net/get-direct/nubNH6Z6vqKZZtboVlYcQg/y80 losslessly, this will reduce its size by 1.3 KB (19%

5. Reduce server response time - this is an average error rate. Fixing the error will speed up the site a little.

Based on testing results, your server's response time was 0.24 seconds. This indicator is influenced by many factors. Read our best practices to learn how you can track and measure response times.

I didn’t think it was a lot, but it seems to be a hosting issue, you need to find out there.
6. Shorten the HTML - This is a medium error rate. Fixing the error will speed up the site a little.
Compressing HTML code (including inline JavaScript or CSS code) reduces the amount of data for faster loading and processing times.

Minify the HTML code in the following resources to reduce their size by 1.7 KB (8%
Reducing https://prostolinux.ru/kak-usilit-signal-3g-modema/ will reduce the size by 1.7 KB (8%

For mobile:

Here all the errors are the same, but with the difference that ALL OF THEY ARE MARKED AS CRITICAL!

What does this mean? This means that when loading a site from mobile device, everything should be much faster, since the Internet channel is usually narrower there.

Yes, I didn't say where Google showed me these errors. And he showed them to me in the Google Adsense panel. Or you can simply go to https://developers.google.com/speed/pagespeed/insights/ and find out what needs to be fixed, because optimizing the code on the site, although not easy, only needs to be done once.

If you know how to solve at least some problems, I will be very grateful for your tips. In the meantime, I will scour the Internet in search of answers to these important questions...

Solutions.

1. Turn on compression.

The first thing that made it possible to immediately achieve some improvements was adding code to the .htaccess file, which is located in the root of the site.

SetOutputFilter DEFLATE Header append Vary User-Agent FileETag MTime Size ExpiresActive on ExpiresDefault "access plus 1 month" SetOutputFilter DEFLATE

As I understand it, all this allows you to compress data on the server side. I already wrote about this before, even published the code, but you can add a couple more settings to this that improved the performance.
2. Remove unnecessary scripts.

Analysis of the page showed that some template scripts were preventing the page from loading. I removed several scripts of this type from header.php:

© 2024 ermake.ru -- About PC repair - Information portal