Optimizing and Compressing CSS in Page Speed ​​- How to disable external style files and merge them into one for faster loading. Optimization (removing code from the top of the page, bundling, compressing) CSS and scripts, and setting up jQuery loading from Google

Ladies and gentlemen, let's turn on the paranoia:

However, if we consider the average result, then 2 tools stand out with a fairly large margin:

1. cssresizer.com (84.13%);

whois spoiler

[email protected]:~$ whois cssresizer.com

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registers. Go to http://www.internic.net
for detailed information.

Domain Name: CSSRESIZER.COM
Registrar: REGISTRAR OF DOMAIN NAMES REG.RU LLC
Sponsoring Registrar IANA ID: 1606
Whois Server: whois.reg.com
Referral URL: http://www.reg.ru
Name Server: NS1.MCHOST.RU
Name Server: NS2.MCHOST.RU
Name Server: NS3.MCHOST.RU
Name Server: NS4.MCHOST.RU
Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Updated Date: 21-apr-2016
Creation Date: 08-apr-2016
Expiration Date: 08-apr-2017

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar "s sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant"s agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar"s reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services" ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). compilation,
repackaging, dissemination or other use of this Data is expressly
without prohibited the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

Domain name: cssresizer.com
Domain idn name: cssresizer.com
Status: clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited
Registry Domain ID:
Registrar WHOIS Server: whois.reg.com
Registrar URL: https://www.reg.com/
Registrar URL: https://www.reg.ru/
Registrar URL: https://www.reg.ua/
updated date:
Creation Date: 2016-04-08T14:01:10Z
Registrar Registration Expiration Date: 2017-04-08
Registrar: Registrar of domain names REG.RU LLC
IANA Registrar ID: 1606
Registrar Abuse Contact Email: [email protected]
Registrar Abuse Contact Phone: +7.4955801111
Registry Registrant ID:
Registrant ID:
Registrant Name: Protection of Private Person
Registrant Street: PO box 87, REG.RU Protection Service
Registrant City: Moscow
Registrant State/Province:
Registrant Postal Code: 123007
Registrant Country: RU
Registrant Phone: +7.4955801111
Registrant Phone Ext:
Registrant Fax: +7.4955801111
Registrant FaxExt:
Registered Email: [email protected]
Admin ID:
Admin Name: Protection of Private Person
Admin Street: PO box 87, REG.RU Protection Service
Admin City: Moscow
Admin State/Province:
Admin Postal Code: 123007
Admin Country: RU
Admin Phone: +7.4955801111
Admin PhoneExt:
Admin Fax: +7.4955801111
Admin FaxExt:
Admin Email: [email protected]
Tech ID:
Tech Name: Protection of Private Person
Tech Street: PO box 87, REG.RU Protection Service
Tech City: Moscow
Tech State/Province:
Tech Postal Code: 123007
Tech Country: RU
Tech Phone: +7.4955801111
Tech Phone Ext:
Tech Fax: +7.4955801111
Tech Fax Ext:
tech email: [email protected]
Name Server: ns1.mhost.ru
Name Server: ns2.mhost.ru
Name Server: ns3.mhost.ru
Name Server: ns4.mhost.ru
DNSSEC: Unsigned
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
>>> Last update of WHOIS database: 2016-07-27T00:49:39Z<<<

For more information on Whois status codes, please visit
https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en.

% By submitting a query to REG.RU Whois Service
% you agree to abide by the following terms of use:
% http://www.reg.ru/whois/servpol (in Russian)
% http://www.reg.com/whois/servpol (in English)

And again:

with a fairly large margin, 2 instruments stand out

I almost forgot

This is the process of removing unnecessary or redundant code in CSS files in order to reduce the file size in order to increase page loading speed.
We bring to your attention 10 CSS Optimization Tools who can help you organize and optimize your css code quickly and easily.

stylestats

The StyleStats service collects and analyzes CSS statistics for any website. Shows errors and gives advice on how to fix them.

Critical Path CSS Generator

Online tool for acceleration and optimization of site loading speed.
We've all experienced the problem of waiting for the page to render until all the plugins and styles have loaded. Sometimes on heavy sites it takes a long time to load all the files. By using the Critical Path CSS Generator service, you can get around this problem. It allows you to generate CSS code in such a way that when opening the page, the part was instantly loaded up to the so-called newspaper bend(first screen). This method has a positive effect on search engine optimization.

Helium

Helium is a scripted tool for unused CSS detection on website pages. It is powered by and runs in the browser.

CSS Ratiocinators

CSS Ratiocinator will automatically reshape your CSS and generate a new style sheet with more elegant and concise code, while cleaning up unnecessary properties that are inherited by child elements. The script generates new styles based on the element tree (DOM). The end result should be clean and optimized CSS code.

CSS Lint

CSS optimization service- CSS Lint indicates problems with your CSS code. His tasks include troubleshooting and signs of inefficiency.

Good afternoon! For a long time I did not have notes on technical optimization, so today the story will be about css compression.

The question immediately arises - why is this necessary? The answer is simple: by optimizing style sheets, the downloaded amount of code is reduced, the weight of the style.css file is reduced. As a result, the page will weigh less, which means saving traffic and increasing the speed of loading the site.

In addition, Google recognizes the speed of loading an Internet page as one of the search results.

Agree, even despite the high bandwidth of modern provider channels and the ubiquitous unlimited Internet, this is a significant factor. Therefore, I strongly recommend paying attention not only to, but also to its size.

How to Optimize CSS and Reduce File Size

Optimization can be approached in various ways. The safest is to manually clean up the stylesheet. Although one can argue, because an unknowing person can do such a thing that the devil will break his leg, and you still can’t achieve maximum compression.

What activities can be carried out when optimizing CSS:

  • Remove unused selectors.
  • Remove unused commented lines.
  • Reduce the amount of comments in the style file. It is always convenient when elements are grouped according to a common feature and have comments invisible to the eyes of ordinary users. But often, in order to achieve a high degree of CSS compressibility, you have to get rid of them. To make it easier to navigate in the code later on, you can still use them, but leave short descriptions.
  • Remove blank lines and spaces. But you should not get carried away too much, the code should remain readable in order to easily make edits.
  • Merge elements with the same properties.
  • Optimize fonts. Better to use one font. In each individual block of the page, using a different font is bad form and, as you can see, overloads the style file.
  • Optimize colors. This is quite simple to do, but it is difficult to explain in words, so I will give illustrative examples:
#ffffff replace with #fff #112233 replace with #123
  • Optimize padding. Again with examples:
  • padding :10px 20px 10px 20px ; replace with padding :10px 20px ; padding :10px 0px 0px 0px ; replace with padding :10px 0 0; padding :10px 10px 10px 10px ; replace with padding :10px ;

    Of course, you can find other ways to optimize, but I’ll stop here and continue my story about online CSS optimization tools.

    CSS optimization with online services

    All online services must be treated with extreme caution and care so as not to break firewood. And without fail - make a backup copy, however, this recommendation applies to all files that are being edited.

    There are a number of online tools (CleanCSS, Online CSS Optimizer, etc.) that can perform CSS optimization. They are not much different from each other, often using the same algorithms and compression libraries, such as YUICompressor or CSSTidy.

    I will dwell on the one that I use most often. This is the CSS optimizer on the webmaster portal CY-PR.com.

    To get started, you need to paste a CSS snippet or the entire contents of a stylesheet into the text field. On the right in the drop-down list, use quick settings:

    • maximum (the code is not readable, the smallest size);
    • high (tolerable readability, small size);
    • standard (balance between readability and size);
    • low (readable code);
    • choose yourself (enter the parameters below).

    For safe optimization, it is recommended to use standard compression. For fun, use the other quick settings, but remember to back up. After the CSS compression parameters are set, you can start the direct work of the script by pressing the button Optimize CSS.

    The results are displayed below with the original and optimized code size, as well as the compression ratio as a percentage:

    And the last addition: try to merge CSS files. Some plugins use their own styles stored in separate files, it would be nice to combine them into one. Next time in this column, I will tell you how you can automatically get compressed CSS as output. See you soon!

    While optimizing their sites, most webmasters (the author of this blog is no exception) completely forget about Cascading Style Sheets (CSS) optimization as one of the components of any Internet resource.

    Putting the display styles of various page elements into a separate file certainly speeds up the loading of site pages, since the CSS file is cached by the browser (if such a function is allowed to it) and subsequently loads it not from the Internet, but directly from your computer.

    But even in this case, you can get even more effect from the use of cascading style sheets (which sometimes take tens of kilobytes of code), by optimizing this very CSS.

    And here simple and easy-to-use online services come to the rescue - CSS Optimizers.

    By searching Google, I found several similar tools that are ready to help solve the problem (all bourgeois services):

    What do these services do? to get a result. They combine homogeneous classes, remove unnecessary properties, spaces, indents, and so on. The result is unreadable code for the webmaster, but when optimizing the largest CSS file, the difference in page loading becomes significant.

    Many broadband Internet users will see no point in this, since most of their sites open quickly. But imagine if every site starts to load at least 10% faster, then how much time will you save in a week, a month? And for a year? At the same time, it is worth considering the fact of saving traffic. She can be impressive too. After all (to paraphrase a well-known proverb) a kilobyte saves a megabyte;).

    What was tested

    To test the optimization results, I used the CSS files of the following sites:

    • Habrahabr - news of the Internet industry;
    • news2 - News 2.0;
    • iXBT.com - IT news;
    • This blog.

    In order not to complicate anything, I left the optimizer settings by default. We will assume that they are optimal and intended for the average user.

    Test results

    Service / After optimization / Decrease, % / Comments

    Tested first Habrahabr with his 40.69 kilobyte CSS.

    • CSS Optimizer / 23.25 KB / 42.86% / Decreased line height, some headings lost boldness, reduced the font of some links. In principle, even these shortcomings do not interfere with the convenience of viewing the page, since the changes concern secondary elements.
    • Clean CSS / 29.13 KB / 30.1% / Nothing has changed.
    • CSS Compressor / 21.69 KB / 46.7% / No changes either.

    Next come "News 2.0". CSS size - 18.15KB.

    • CSS Optimizer / 10.46 KB / 42.34% / Virtually no changes have occurred, except for a slight increase in the font in two lines. In general, this did not affect usability in any way.
    • Clean CSS / 11.40 KB / 38.7% / Everything is left in place.
    • CSS Compressor / 8.94 KB / 50.74% / Indents increased, some elements lost centering, styles for some types of links got corrupted.

    Now we test iXBT.com. CSS size - 15.47KB.

    • CSS Optimizer / 11.60 KB / 25.06% / The right column floats down, which definitely affects usability.
    • Clean CSS / 11.74 KB / 24.4% / Just a slight change in indentation in some places.
    • CSS Compressor / 7.32 KB / 51.75% / Total distortion of the page appearance. She is simply unrecognizable.

    CSS gets tested last my blog. Its size is 12.02KB.

    • CSS Optimizer / 7.60 KB / 36.75% / White background disappears, indents of some elements and line height change.
    • Clean CSS / 9.65 KB / 24.5% / Everything is in its place.
    • CSS Compressor / 4.74 kB / 60.54% / Page formatting is completely lost. "Do not climb into any gate."

    Drawing conclusions

    The Clean CSS service showed the best results in terms of quality/size ratio. CSS, optimized through it, left everything in its place on all tested sites. Moreover, the file size on average shrinks by a whole third. In addition, the code itself, with default settings, is not raked into a heap, but remains as readable as in the original version.

    Moreover, the service shows the full changelog, ie. what and in which line was corrected, and the code is displayed with syntax highlighting. Therefore, this service deserves praise and it is boldly can be used for CSS optimization purposes files.

    Using the other two options - CSS Optimizer and CSS Compressor - is worth it only in a specific case, "trying on" the correctness of the optimized style file on the site.

    Thus, CSS optimization can significantly speed up the loading of sites without the need to make drastic changes to the page structure. Yes, and it should be borne in mind that the majority of the Internet user is still connected via dial-up.

    And finally.

    Before optimizing CSS files with one of these tools, I would suggest save the original, readable style file so that in the future it will be possible, as before, to make the necessary amendments to it with convenience.

    Online poker is a very popular pastime that allows people to become financially secure. You can download poker and become one of them.

    Do I need to compress CSS code at all?

    First of all, let's define why we need to compress css code? If our css files are small, then there is nothing to show off, but if you are developing a solid project, then this is a completely different story. So you're here to learn how to organize CSS compression. More to the point… CSS compression can be implemented in several ways. Below is a list of all CSS compression methods that I know of.

    CSS compression methods

    Notes: static compression, compresses up to - 80%-90%

    Notes: dynamic compression, compresses up to -75%-95% (depends on you)

    Notes: static compression, compresses up to - 50%

    Just choose the css compression method you like and click on it, or read all the methods and draw your own conclusions, which I strongly recommend to you.

    Compressing CSS with Online Compressors

    Analyzing the work of css compressors, we can draw the following conclusions about the degree of css compression. The experiment was carried out on the basis of two css files with the following parameters:

    first - 7372 bytes

    the second is 62,609 bytes

    The first css is short and readable, so it won't compress well.

    CleanCSS Online Compressor

    Address: www.cleancss.com

    Pretty solid service, let's see the results of its css compression.

    Result:

    the first is compressed to 7,075 bytes (96%)

    the second is compressed to 52,797 bytes (84.3%)

    FormatCSS Online Compressor

    Address: www.lonniebest.com/FormatCSS

    This service is more for formatting css files than for compressing them. The css text is entered using copy/paste.

    Result:

    the first is compressed to 8,105 bytes (109.9%)

    the second is compressed to 61,715 bytes (98.5%)

    OnlinecompressorRobson CSS Compressor

    Address: iceyboard.no-ip.org/projects/css_compressor

    The service is flexible in terms of loading css source code. You can load css into it from a local directory, from the Internet, or copy/paste. Let's look at the results of compressing css files.

    Result:

    the first is compressed to 6,326 bytes (86.3%)

    the second is compressed to 48,985 bytes (78.2%)

    Onlinecsshtml compressor Tabifier

    Address: tools.arantius.com/tabifier

    Allows you to compress not only css, but also html code. But the result is not very impressive, draw your own conclusions.

    Result:

    the first is compressed to 7,876 bytes (106.8%)

    the second is compressed to 60,706 bytes (96.9%)

    Compressing CSS with PHP

    Compressing css with PHP is available in several ways, but I will give only one, the most interesting for my understanding. The advantage of css compression in php is the dynamism and flexibility in terms of compression settings, since you set them yourself using your php script. My script looks like this:

    A very simple and convenient code that you insert into a css file, which must be included in the most familiar way. The peculiarity of this php script is the use of regular expressions, which remove all comments and whitespace characters, thus compressing css.

    Compressing CSS with Base 62

    The method is quite interesting and effective, but it is static, that is, every time you change your css file, you need to go through the css file compression procedure. This procedure is described step by step below.

    1. Compressioncss with compressor

    You need to use one of the css compressors to remove all whitespace and align the css code to one line.

    2. Creationjs file

    You need to create a js file and put the following code in it:

    Document.write("");

    Instead of /*your style */ insert the resulting string in the first paragraph of the compression procedure.

    3. Base 62 compression

    As you can see, now you have a js file that you compress using the service Packer-http://dean.edwards.name/packer/

    Paste the code of your js file into the top field and select the checkbox base62 encode, and then get the result in the bottom field.

    This method allows you to compress a css file from 15kb to 8kb in size, that is, by almost 50%. The advantage of such an intricate procedure is that you insert the resulting code into the js file in which the rest of your js scripts are located and it's all loaded together.

    I posted all my knowledge about compressioncss. If you have any ideas about more efficient compression methodscss, please write in the comments. Thank you for your attention!

    A computer