{"id":4827,"date":"2021-05-28T18:18:14","date_gmt":"2021-05-28T18:18:14","guid":{"rendered":"https:\/\/www.s-sols.com\/?post_type=doc&#038;p=4827"},"modified":"2026-03-20T16:33:15","modified_gmt":"2026-03-20T16:33:15","slug":"settings-html-accel","status":"publish","type":"doc","link":"https:\/\/www.s-sols.com\/docs\/wordpress\/accelerator\/settings-accel\/settings-html-accel","title":{"rendered":"HTML settings Accelerator for WordPress"},"content":{"rendered":"<p style=\"text-align:center\">\n  <img decoding=\"async\" src=\"\/data\/content\/doc\/wordpress\/accelerator\/settings-html-accel\/settings-html-en.png\" alt=\"settings-HTML\" title=\"settings-HTML - HTML settings\" \/>\n<\/p>\n<h2><a id=\"general\"><\/a>General<br \/>\n<\/h2>\n<ul>\n<li><strong>Minify<\/strong>\n<p style=\"text-align:left\">\n      Optimizes HTML code to have a smaller size.\n    <\/p>\n<\/li>\n<li><strong>Early paint<\/strong>\n<p style=\"text-align:left\">\n      Forces the page\u2019s biggest part to being painted as earlier as possible.\n    <\/p>\n<\/li>\n<\/ul>\n<h2><a id=\"fix\"><\/a>Fix markup<br \/>\n<\/h2>\n<ul>\n<li><strong>Basic<\/strong>\n<p style=\"text-align:left\">\n      Corrects the most common and simple errors like unescaped tags in scripts.\n    <\/p>\n<ul>\n<li><strong>Embedded scripts and styles encoding correction<\/strong>\n<p style=\"text-align:left\">\n          Determining encoding of assets and converting it to HTML\u2019s encoding.\n        <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>Additional<\/strong>\n<p style=\"text-align:left\">\n      Tries to normalize HTML markup and correct missed or wrong placed tags.\n    <\/p>\n<\/li>\n<li><strong>Advanced by &#8216;Tidy&#8217;<\/strong>\n<p style=\"text-align:left\">\n      Tries to normalize HTML markup and correct missed or wrong placed tags by special PHP extension &#8216;Tidy&#8217;. This extension should be enabled on the hosting before use.\n    <\/p>\n<p style=\"text-align:left\"><strong>Warning.<\/strong> It can break some tags and should be used if necessary.\n    <\/p>\n<\/li>\n<\/ul>\n<h2><a id=\"cln\"><\/a>Cleanup<br \/>\n<\/h2>\n<h3>\n  Comments<br \/>\n<\/h3>\n<p>\n  Sometimes HTML comments can contain some metainformation that is needed for page display. In this section such comments can be excluded from minification by adding <a href=\".\/regexp-accel\">regular expression<\/a> patterns. It can be added multiple expressions at once by placing each on new line.\n<\/p>\n<h3>\n  Elements<br \/>\n<\/h3>\n<p>\n  In this list any <a href=\".\/xpath-elements-selector-accel\">XPath expressions<\/a> of needed elements and attributes can be specified. It can be added multiple expressions at once by placing each on new line.\n<\/p>\n<p>\n  E.g. expression <code>.\/\/h1<\/code> will clean all <code>h1<\/code> tags. Or expression <code>.\/\/h1\/@class<\/code> will clean <code>class<\/code> attribute from all <code>h1<\/code> tags.\n<\/p>\n<h2><a id=\"repl\"><\/a>Replacement<br \/>\n<\/h2>\n<p>\n  It allows replacing content in raw HTML code.\n<\/p>\n<ul>\n<li><strong>Apply even to non-cached content<\/strong>\n<p style=\"text-align:left\">\n      If enabled, this replacement will apply to all pages containing HTML.\n    <\/p>\n<\/li>\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\">\n      Simple string or regular expression. Unchecking related checkbox allows to disable the element.\n    <\/p>\n<\/li>\n<li><strong>Scope<\/strong>\n<p style=\"text-align:left\">\n      If scope (element(s) XPath selector) is specified, replacement is occurred only in that elements\u2019 HTML.\n    <\/p>\n<p style=\"text-align:left\"><strong>Note:<\/strong> such items processed always after all items without scope.\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\">\n      Replacement content.\n    <\/p>\n<\/li>\n<\/ul>\n<p>\n  Unnamed group is a placeholder for replacement. To make simple insertion just use empty unnamed group like this <code>@&lt;span\\sa=\"1\"&gt;()@<\/code>. Named groups can be used to extract data from source, e.g. <code>@&lt;span\\sa=\"(?'attr_a'[^\"]*)\"&gt;()@<\/code> with replacement <code>${attr_a}<\/code> puts value of attribute <code>a<\/code> in the tag body.\n<\/p>\n<h3>\n  Example 1<br \/>\n<\/h3>\n<p>\n  Simple replacement of string &#8216;abc&#8217; to string &#8216;bca&#8217;.\n<\/p>\n<ul start=\"5\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>abc<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>bca<\/code>\n    <\/p>\n<\/li>\n<\/ul>\n<h3>\n  Example 2<br \/>\n<\/h3>\n<p>\n  Inserting \u2018wpadminbar\u2019 if it is not found (conditional replacement).\n<\/p>\n<ul start=\"7\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>!@\\Wid=\"wpadminbar\"@ &amp; @()&lt;\/body&gt;@<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>&lt;div id=\"wpadminbar\"&gt;&lt;\/div&gt;<\/code>\n    <\/p>\n<\/li>\n<\/ul>\n<h3>\n  Example 3<br \/>\n<\/h3>\n<p>\n  Adding <code>fetchpriority=\"high\"<\/code> attribute to the first element with <code>img<\/code> tag.\n<\/p>\n<ul start=\"9\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>@^&lt;\\w+()@<\/code>\n    <\/p>\n<\/li>\n<li><strong>Scope<\/strong>\n<p style=\"text-align:left\"><code>(.\/\/img)[1]<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>\u00a0fetchpriority=\"high\"<\/code>\n    <\/p>\n<p style=\"text-align:left\"><strong>Warning:<\/strong> please, don\u2019t miss the space before the code while copying.\n    <\/p>\n<\/li>\n<\/ul>\n<h3>\n  Example 4<br \/>\n<\/h3>\n<p><strong>Add<\/strong> some element (e.g. simple <code>div<\/code>) as <strong>the<\/strong> <strong>first<\/strong> element <strong>of the body<\/strong>.\n<\/p>\n<ul start=\"12\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>@&lt;body[^&gt;]*&gt;()@<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>&lt;div&gt;first&lt;\/div&gt;<\/code>\n    <\/p>\n<\/li>\n<\/ul>\n<h3>\n  Example 5<br \/>\n<\/h3>\n<p><strong>Add<\/strong> some element (e.g. simple <code>div<\/code>) as <strong>the<\/strong> <strong>last<\/strong> element <strong>of the body<\/strong>.\n<\/p>\n<ul start=\"14\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>@()&lt;\/body&gt;@<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>&lt;div&gt;last&lt;\/div&gt;<\/code>\n    <\/p>\n<\/li>\n<\/ul>\n<h3>\n  Example 6<br \/>\n<\/h3>\n<p><strong>Add<\/strong> some element (e.g. simple <code>span<\/code>) <strong>before<\/strong> <strong>particular<\/strong> element (e.g. the second <code>div<\/code> in the <code>body<\/code>).\n<\/p>\n<ul start=\"16\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>@^()@<\/code>\n    <\/p>\n<\/li>\n<li><strong>Scope<\/strong>\n<p style=\"text-align:left\"><code>(.\/\/body\/\/div)[2]<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>&lt;span&gt;before&lt;\/span&gt;<\/code>\n    <\/p>\n<\/li>\n<\/ul>\n<h3>\n  Example 7<br \/>\n<\/h3>\n<p><strong>Add<\/strong> some element (e.g. simple <code>span<\/code>) <strong>after<\/strong> <strong>particular<\/strong> element (e.g. the second <code>div<\/code> in the <code>body<\/code>).\n<\/p>\n<ul start=\"19\">\n<li><strong>Search<\/strong>\n<p style=\"text-align:left\"><code>@()$@<\/code>\n    <\/p>\n<\/li>\n<li><strong>Scope<\/strong>\n<p style=\"text-align:left\"><code>(.\/\/body\/\/div)[2]<\/code>\n    <\/p>\n<\/li>\n<li><strong>Replace<\/strong>\n<p style=\"text-align:left\"><code>&lt;span&gt;after&lt;\/span&gt;<\/code>\n    <\/p>\n<\/li>\n<\/ul>\n<h2>\n  Always fresh parts<br \/>\n<\/h2>\n<p>\n  On some sites there are content parts that always should be loaded without caching to show actual (fresh) content. As a result, most of content is load instantly and specified parts will be loaded with a little delay and always actual.\n<\/p>\n<p>\n  In this list any <a href=\".\/xpath-elements-selector-accel\">XPath expressions<\/a> of needed elements can be specified.\n<\/p>\n<p><a id=\"_Hlk156155112\"><\/a><\/p>\n<p>\n  To remove the display delay, you need to write<span style=\"font-size:12pt\"> <\/span><code>sa:<\/code><span style=\"font-size:12pt\"> before the expression<\/span> (&#8216;sa&#8217; means &#8216;show always&#8217;). In this case, the element will always be displayed first in its original (not fresh) form.\n<\/p>\n<p><a id=\"lazy\"><\/a><strong>Warning.<\/strong> Elements should always exist. If it doesn\u2019t, it can be inserted by defining related <a href=\"#repl\">HTML replacements<\/a>.\n<\/p>\n<p><strong>Warning.<\/strong> Elements should be specified by its containing parent due to replacement is going only of element\u2019s children.\n<\/p>\n<p><strong>Warning.<\/strong> The amount of chosen parts shouldn\u2019t be variable per request. Otherwise, fresh parts can be wrong replaced. E.g. the price blocks in the product list are chosen as fresh parts. And because the list of products may change in subsequent requests, then the prices may be incorrectly replaced.\n<\/p>\n<p><strong>Warning.<\/strong> This approach requires fast work of server due to one per <a href=\".\/settings-revalidation-accel#int\">specified seconds<\/a> these elements are reloaded from original page content.\n<\/p>\n<h3>\n  Examples<br \/>\n<\/h3>\n<h4>\n  Simple<br \/>\n<\/h4>\n<p>\n  Here is HTML code:\n<\/p>\n<p><code class=\"p\">&lt;p&gt;<br \/>    Some text 1\u2026<br \/>&lt;\/p&gt;<br \/>&lt;p&gt;<br \/>    &lt;img src=\"test-img-01.jpg\"&gt;<br \/>    Some text 2\u2026<br \/>&lt;\/p&gt;<\/code>\n<\/p>\n<p><a id=\"_Hlk156154979\"><\/a><\/p>\n<p>\n  And an expression for a paragraph that has an image inside that contains <code>test-img-01<\/code> in the file name: <code>.\/\/p[.\/\/img[contains(@src, \"test-img-01\")]]<\/code>.\n<\/p>\n<h4>\n  WooCommerce always fresh prices, sales, etc.<br \/>\n<\/h4>\n<p>\n  Summary block on product page:\n<\/p>\n<p><code class=\"p\">sa:.\/\/body[contains(concat(\" \",normalize-space(@class),\" \"),\" single-product \")]\/\/*[contains(concat(\" \",normalize-space(@class),\" \"),\" entry-summary \")]<\/code>\n<\/p>\n<p>\n  Any product lists on any page (related products, categories, etc):\n<\/p>\n<p><code class=\"p\">sa:.\/\/ul[contains(concat(\" \",normalize-space(@class),\" \"),\" products \")]<\/code>\n<\/p>\n<p>\n  So, now all sales, prices will be shown immediately.\n<\/p>\n<h2>\n  Lazy load parts<br \/>\n<\/h2>\n<p>\n  A <a href=\".\/lazy-html-accel\">special efficient technology<\/a> for speeding up the loading of very large numbers of DOM elements. It is configured for each site individually.\n<\/p>\n<ul start=\"4\">\n<li><strong>Load before non-critical scripts<\/strong>\n<p style=\"text-align:left\">\n      In most cases all HTML should be loaded before main scripts. But can be a case when site\u2019s layout allows loading HTML parts as they displaying when scrolling.\n    <\/p>\n<\/li>\n<li><strong>Storing as attributes<\/strong>\n<p style=\"text-align:left\">\n      In this mode,<span style=\"font-size:12pt\"> <\/span>the HTML<span style=\"font-size:12pt\"> <\/span>is stored in an attribute instead of a<span style=\"font-size:12pt\"> <\/span><code>noscript<\/code><span style=\"font-size:12pt\"> tag<\/span>, allowing, for example,<span style=\"font-size:12pt\"> using <\/span>Google Translate Cloud.\n    <\/p>\n<\/li>\n<li><strong>Selectors list<\/strong>\n<p style=\"text-align:left\">\n      Here you can specify which parts of the pages, via their selectors (<a href=\".\/xpath-elements-selector-accel\">XPaths<\/a>), should be lazy loaded. Since<span style=\"font-size:12pt\"> <\/span>XPath language it is an analogue of<span style=\"font-size:12pt\"> <\/span>CSS, it allows you to make settings both for individual pages and for their set, using the principle of<span style=\"font-size:12pt\"> <\/span>CSS<span style=\"font-size:12pt\"> <\/span>selectors (classes, tags, properties, &#8230;). It can be added multiple selectors at once by placing each on new line.\n    <\/p>\n<p style=\"text-align:left\">\n      Also, there are <strong>special parameters<\/strong> that are specified at the begin of each XPath selector. It allows to adjust behavior:\n    <\/p>\n<ul>\n<li><strong>bjs<\/strong>\n<p style=\"text-align:left\">\n          Always loading before main scripts. It overrides default &#8216;<strong>Load before non-critical scripts<\/strong>&#8216; setting. Values:\n        <\/p>\n<ul>\n<li><strong>0<\/strong>\n<p style=\"text-align:left\">\n              Disables.\n            <\/p>\n<\/li>\n<li><strong>1, yes, on<\/strong>\n<p style=\"text-align:left\">\n              Enables.\n            <\/p>\n<\/li>\n<li><strong>only<\/strong>\n<p style=\"text-align:left\">\n              Enables loading only before main JS.\n            <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>height<\/strong>\n<p style=\"text-align:left\">\n          Height in CSS size of each block. E.g. <code>height=100px<\/code> or <code>height=50em<\/code>. Default is 10em.\n        <\/p>\n<\/li>\n<li><strong>sep<\/strong>\n<p style=\"text-align:left\">\n          Loading lazy HTML parts by separate request starting from specified index of lazy block. It is needed only to decrease page size if it is very large (e.g. more than 500 KB).\n        <\/p>\n<\/li>\n<li><strong>chunk<\/strong>\n<p style=\"text-align:left\">\n          Specifies chunk size when dividing to lazy loading blocks. It is 8K bytes by default.\n        <\/p>\n<\/li>\n<li><strong>chunkSep<\/strong>\n<p style=\"text-align:left\">\n          Specifies chunk size when dividing to lazy separated loading blocks. It is 512K bytes by default.\n        <\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\n  Also, there is a special XPath function <strong>followingSiblingUpToParent<\/strong> that allows to mark <a href=\"#below_the_fold_setup\"><strong>below the fold content<\/strong><\/a>. First parameter is element\u2019s path where to start after that. The second optional parameter is parent element\u2019s path to search only within it. See examples below.\n<\/p>\n<h3><a id=\"below_the_fold_setup\"><\/a>How to setup delay loading of below the fold content<br \/>\n<\/h3>\n<p>\n  In Google Chrome browser open needed page.\n<\/p>\n<ol>\n<li>\n  Then <strong>scroll<\/strong> down two screens (if we divided our page to device screen height, we should be on 3<sup>rd<\/sup> now)<a id=\"_Hlk142003603\"><\/a>.\n<\/li>\n<li>\n  Then <strong>choose<\/strong> the bottom <strong>element<\/strong> that will be the last above the fold content and <strong>copy<\/strong> its <strong>XPath selector<\/strong> in the inspector\u2019s DOM tree. E.g. its is <code>\/\/*[@id=\"post-1\"]\/div\/p[12]<\/code>.\n<\/li>\n<li>\n  Then <strong>add<\/strong> it to <strong>lazy load parts<\/strong> setting by including to <strong>followingSiblingUpToParent<\/strong> function like <code>followingSiblingUpToParent(\/\/*[@id=\"post-1\"]\/div\/p[12])<\/code>.\n<\/li>\n<\/ol>\n<p>\n  That is all. After that, do not forget to <a href=\".\/status-and-operations-accel#operate\">update the cache<\/a>.\n<\/p>\n<h3>\n  Examples<br \/>\n<\/h3>\n<p>\n  For example, here is a page with some<span style=\"font-size:12pt\"> <\/span>HTML code:\n<\/p>\n<p><code class=\"p\">&lt;!DOCTYPE html&gt;<br \/>&lt;html&gt;<br \/>&lt;body class=\"home\"&gt;<br \/>    &lt;div&gt;...&lt;\/div&gt;<br \/>    &lt;div&gt;...&lt;\/div&gt;<br \/>    &lt;div&gt;...&lt;\/div&gt;<br \/>&lt;\/body&gt;<br \/>&lt;\/html&gt;<\/code>\n<\/p>\n<p>\n  And then, for example, so that on all pages everything that comes after the second <code>div<\/code> block, loaded lazily, you need to add the rule:\n<\/p>\n<p><code class=\"p\">(.\/\/body\/child::div)[2]\/following-sibling::*<\/code>\n<\/p>\n<p>\n  Or, for example, if you need to do this only for pages that have a <code>home<\/code> class in the <code>body<\/code> tag and the <code>div<\/code> tag is not important, the expression will be:\n<\/p>\n<p><code class=\"p\">(.\/\/body[contains(concat(\"\", normalize-space(@class), \"\"), \" home \"]\/child::*)[2]\/following-sibling::*<\/code>\n<\/p>\n<p>\n  Or, for example, if you need to do this only element that has more than 10 children and starting only after 11th child:\n<\/p>\n<p><code class=\"p\">.\/\/*[count(*)&gt;10]\/*[10]\/following-sibling::*<\/code>\n<\/p>\n<p>\n  Or, if we need to make lazy all <strong>below the fold content<\/strong> (the 2nd <code>div<\/code> in our case), the expression will be:\n<\/p>\n<p><code class=\"p\">followingSiblingUpToParent((.\/\/body\/child::div)[2])<\/code>\n<\/p>\n<p>\n  If we need to limit searching only in <code>body<\/code> the it will be:\n<\/p>\n<p><code class=\"p\">followingSiblingUpToParent((.\/\/body\/child::div)[2], .\/\/body)<\/code>\n<\/p>\n<p>\n  Here is an example of using <strong>special parameters<\/strong>. Loading all lazy blocks before main scripts, each lazy block is minimum 1000 bytes and starting from 4<sup>th<\/sup> lazy block making it separated with minimum size of 100000 bytes:\n<\/p>\n<p><code class=\"p\">bjs=1,sep=4,chunk=1000,chunkSep=100000:.\/\/*[contains(concat(\" \",normalize-space(@class),\" \"),\" entry-content \")]\/*[16]\/following-sibling::*<\/code>\n<\/p>\n<p>\n  If is needed to have only one separated block (to have only one request) then:\n<\/p>\n<p><code class=\"p\">bjs=1,sep=4,chunk=1000,chunkSep=999999999:.\/\/*[contains(concat(\" \",normalize-space(@class),\" \"),\" entry-content \")]\/*[16]\/following-sibling::*<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>General Minify Optimizes HTML code to have a smaller size. Early paint Forces the page\u2019s biggest part to being painted as earlier as possible. Fix markup Basic Corrects the most common and simple errors like unescaped tags in scripts. Embedded scripts and styles encoding correction Determining encoding of assets and converting it to HTML\u2019s encoding&#8230;.<\/p>\n","protected":false},"author":18,"featured_media":0,"parent":4812,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"rank_math_lock_modified_date":false},"categories":[816],"tags":[],"class_list":["post-4827","doc","type-doc","status-publish","hentry","category-accelerator"],"_links":{"self":[{"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/doc\/4827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/doc"}],"about":[{"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/types\/doc"}],"author":[{"embeddable":true,"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/comments?post=4827"}],"up":[{"embeddable":true,"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/doc\/4812"}],"wp:attachment":[{"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/media?parent=4827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/categories?post=4827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.s-sols.com\/api\/wp\/v2\/tags?post=4827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}