head
section is analyzed for CSS and JavaScript files, and when static hosts exist, images are distributed over them (the addresses of images change), and blocks with ads and counters are transferred before </body>
(again, only enable the corresponding setting). Also, HTML is minimized (unnecessary line breaks and indents are removed, comments can be deleted, and in general all unnecessary characters, but these are resource-intensive operations, and by default they are turned off).
cache
folder in the Web Optimizer itself.java
is available). You can also compress JavaScript using the Dean Edwards Packer (it is the best choice in the absence of gzip
compression). Here you can also configure how to minimize the output HTML-code (simple deletion of extra line breaks and spaces, “stretching” in one line and (li) deleting comments). Conditional comments for IE are not affected in any way.<script>
). Here you can customize and “glue” the CSS code located in <style>
(enabled by default). You can also specify (separated by a space) file names (names, not full paths) that should be excluded from the merge logic. During the testing phase, it was discovered that it was impossible to combine the source libraries of the Tiny MCE and the FCE Editor, so they are excluded by default.<body>
(or even cause it to load on the DomContentLoaded
event), you can put the download of some counters, ads and informers to the bottom of the document (after the JavaScript code, the resulting HTML code is inserted into the original place on the page, ensuring the gradual appearance of additional ad units after the main content has been loaded)..htaccess
(for CSS- and JavaScript- in a static form). When it is impossible to change .htaccess
gzip-versions of JavaScript and CSS-code are saved in caching directories, which also reduces the load on the processor (via PHP) to a minimum..htaccess
; for other files, they are duplicated as needed via PHP. By default, static files are set to a caching period of 10 years (when files change, new versions have a different name, based on the md5 hash of the total file contents). For HTML files, it is possible to manually set the appropriate expiration date of the client cache. The difference between this setting and the following group (server-side caching of HTML files) is that the HTML output is not saved on the server in any way, we only indicate to browsers that they may not re-request HTML documents for a certain time. Whether browsers will follow this directive or not remains entirely in their conscience.repeat-x
and repeat-y
will be combined without taking into account the actual size of the containers), adding free space (avoiding rudiments when scaling such images in modern browsers).
data:URI
technology allows you to include background images directly in the CSS file. Supported by all modern browsers and IE8. It has an image size limit of 24 KB (32 KB data:URI
code is derived from 24,576 bytes of the binary code). When creating a data:URI
for IE7, hacks are inserted into the CSS file, which makes the site design unchanged for these browsers. Also, when creating a data:URI
it is highly desirable to optimize images. This is done using the smush.it API. To correctly optimize images, you need write access for the web server to the images themselves. This setting is disabled by default, because it makes sense to optimize images only once, and use the ready-made result on subsequent builds of CSS files.After that, you can addServerAlias ​​i1.site.ru ServerAlias ​​i2.site.ru
i1 i2
to the list of hosts for Web Optimizer and make sure that the images are scattered across these hosts. When installing Web Optimizer, a number of hosts are automatically checked for the possibility of their use as alternative (with the same site root), and all manually specified hosts are checked for availability (test images are loaded from them). It should be borne in mind that if you turn on the “safe” installation (about it below), the host check becomes inaccessible and you will need to register it manually without restarting the Web Optimizer setting..htaccess
. Most of the gzip-compression and caching settings can be recorded in your server's configuration file to avoid additional work on the server-side scripts. This can be done using the .htaccess
file (if necessary, you can later transfer all the settings yourself to the httpd.cond
file). Web Optimizer automatically checks available modules and configures the entry to . htaccess
. htaccess
(of course, for this, the latter must be available for writing). mod_gzip
, mod_deflate
and mod_filter
are responsible for on-the-fly file compression, mod_rewrite
and mod_mime
are for static archiving. mod_headers
and mod_setenvif
- for ensuring correct processing of compressed files on proxying servers and in old browsers. mod_expires
- for exhibiting cache eagolovkov. It is also possible to locate .htaccess
either in the site directory (this is useful if there are several sites on different directories on the same host) or at the very root of the site. By default, both locations are the same. It is also possible to protect a Web Optimizer installation with .htpasswd
. In this case, to access the settings, you will need to enter your login and password through the HTTP Basic Authorization window in the browser (this allows Web Optimizer to be placed in an arbitrary directory within the site, after placing the caching directories outside the protected area)./index.php
. Web Optimizer supports automatic change of files required for correct operation for several dozen CMS (in the case of an unknown system, its name is displayed as CMS 42, and the root index.php
always changed). Before the file is automatically modified, chain site optimization is launched to create all caching files and to avoid long loading of the main page of the site for the first time.Include external JavaScript files and embedded code -> Exclude files from a union -> comma-separated list of files
If desired, CSS Sprites can be created manually via Auto Sprites , specifying a minimized CSS file (or a combined source file).CSS Sprites -> Apply CSS Sprites -> No
It is also possible that IE6 incorrectly handles the merging of styles (and the background overlay along with a number of other hacks). Then disablingCSS Sprites -> Exclude IE6 (via hacks) from creating CSS Sprites -> yes
data:URI
can helpor generally combining CSS files:Data: URI -> Apply data: URI -> no
Compression settings -> Minimize and merge CSS files -> no
htpasswd
. To do this, enable:At the same time, you need to make sure that theUsing .htaccess -> Protect Web Optimizer installation with htpasswd -> yes
are located outside the folder with the Web Optimizer itself (otherwise everything will fall apart for all site visitors except yourself).index.php
):and then at the very bottom of the page:<? php require (/path/k/Web/Optimizer/web.optimizer.php); ?>
Since in the planned mode (after creating all the caching files), Web Optimizer logic execution takes 5-10ms, this will not affect the server side of the download, but the client side will be significantly accelerated. You just have to make sure that the pages to which you add Web Optimizer calls will be processed through the PHP interpreter (they will have the extension<? php $ web_optimizer-> finish (); ?>
.php
or some other one defined by the server settings).dev.site.ru
By running, for example, wget
we get an optimized "cast" of the site, which can be downloaded already in the working system.wget -d -r -c http://dev.site.ru/
It should be immediately noted that these settings add additional load on the server (correct regular expression is quite resource-intensive) and can lead to cutting out some JavaScript-code (which is inserted through comments). Also, the code inside theCompression Settings -> Compress HTML to 1 line -> yes Compression Settings -> Delete HTML Comments -> Yes
script
, textarea
, pre
will not change (in accordance with the specification). Therefore, you need to use these settings with great care.as a result, instead of an image (if you have rights to change it), we will get an optimized copy of it. It is better to carry out not on a group of working images, but on their copies, so that you can roll back the changes.<? php require ('/ full / path / to / css.sprites.php'); $ smushit = new css_sprites (); $ smushit-> smushit ('/ full / path / to / image'); ?>
Source: https://habr.com/ru/post/62009/