{"id":505,"date":"2019-12-12T14:23:07","date_gmt":"2019-12-12T14:23:07","guid":{"rendered":"https:\/\/loftocean.com\/doc\/loftloader\/?page_id=505"},"modified":"2020-07-02T06:19:07","modified_gmt":"2020-07-02T06:19:07","slug":"exclude-code-from-caching","status":"publish","type":"page","link":"https:\/\/loftocean.com\/doc\/loftloader\/common-issues\/exclude-code-from-caching\/","title":{"rendered":"Exclude Code from Caching"},"content":{"rendered":"<p>If your website is using a cache\/performance optimization plugin, then it might combine\/minify JavaScript (or\/and CSS) and move them into the footer of your page. Then the preloader may not work properly.<\/p>\n<p>Because the JavaScript (and CSS) of LoftLoader needs to be put in the < head > of a page so it can be executed as soon as possible. Many cache\/performance optimization plugins have the &#8220;<strong>exclude<\/strong>&#8221; feature which allows to skip some code and files from being aggregated and minimized. To solve this kind of problem, please:<\/p>\n<h5>1. Exclude Inline JavaScript<\/h5>\n<p>Please add the following 2 lines to <strong>&#8220;Exclude Inline JavaScript&#8221;<\/strong>. <\/p>\n<p><!--Let's take WP Rocket as an example. This setting can be find here: <strong>WP Rocket Settings<\/strong> > <strong>File Optimization<\/strong> > <strong>Exclude Inline JavaScript<\/strong>.--><\/p>\n<p>In the settings panel of a cache plugin, please find <strong>File Optimization<\/strong> (or <strong>Optimization<\/strong> &#8211; it may be different in each cache plugin)  > <strong>Exclude Inline JavaScript<\/strong>.<\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px;\">\r\nloftloaderPro\r\nloftloaderCache\r\n<\/pre>\n<p>&nbsp;&nbsp;<br \/>\nThen, please always <strong>clear your site cache<\/strong> and <strong>browser cache<\/strong> after making changes, then refresh page and check again.<\/p>\n<p><!--\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/wprocket-file-optimization.png\" alt=\"\" width=\"1150\" height=\"859\" class=\"alignnone size-full wp-image-509\" srcset=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/wprocket-file-optimization.png 1150w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/wprocket-file-optimization-300x224.png 300w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/wprocket-file-optimization-768x574.png 768w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/wprocket-file-optimization-1024x765.png 1024w\" sizes=\"auto, (max-width: 1150px) 100vw, 1150px\" \/>\n\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/exclude-inline-js.png\" alt=\"\" width=\"1150\" height=\"859\" class=\"alignnone size-full wp-image-510\" srcset=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/exclude-inline-js.png 1150w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/exclude-inline-js-300x224.png 300w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/exclude-inline-js-768x574.png 768w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2019\/12\/exclude-inline-js-1024x765.png 1024w\" sizes=\"auto, (max-width: 1150px) 100vw, 1150px\" \/>\n--><\/p>\n<hr>\n<h5>2. Exclude JavaScript files of LoftLoader<\/h5>\n<p>If the problem still persists after excluding inline JavaScript, then please also exclude the <strong>JavaScript files<\/strong> of LoftLoader.<\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px;\">\r\nloftloader-pro\/assets\/js\/jquery.waitformedias.min.js\r\nloftloader-pro\/assets\/js\/loftloader.min.js\r\nwp-includes\/js\/jquery\/jquery.js\r\n<\/pre>\n<p>&nbsp;&nbsp;<\/p>\n<div style=\"border: 1px solid #eee; background:#eee; padding: 50px;\"\">\nAbout the third line of the above code: <\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px; margin-bottom: 30px;\">\r\nwp-includes\/js\/jquery\/jquery.js\r\n<\/pre>\n<p>Some cache plugins may have the option to enable\/disable merging jQuery library. If yes, please disable merging jQuery library. If not, please add the third line of code to manually exclude jQuery.<\/p>\n<hr style=\"background: #fff;\">\n<p>About the first 2 lines of the above code: <\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px; margin-bottom: 30px;\">\r\nloftloader-pro\/assets\/js\/jquery.waitformedias.min.js\r\nloftloader-pro\/assets\/js\/loftloader.min.js\r\n<\/pre>\n<p>If the cache plugin you are using supports the <strong>wildcard character<\/strong>, you can simply replace the above codes with the following line of code. (In software, a wildcard character is a kind of placeholder represented by a single character, such as an asterisk (*), which can be interpreted as a number of literal characters or an empty string.)<\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px; margin-bottom: 30px;\">\r\nloftloader-pro\/(.*).js\r\n<\/pre>\n<\/div>\n<div class=\"info-box\" style=\"background: #FFF; border: 1px solid #DDD;padding: 30px;margin: 30px auto;\">\n<span class=\"highlighted\">Please note:<\/span> Different cache plugins may have different requirements for the path of the code filled in. In this document, we only indicate which JavaScript files of LoftLoader Pro need to be excluded. Please carefully read the documentation of the cache plugin you are using to make sure that the correct file path is filled. For example, <span class=\"highlighted\">&#8220;\/wp-content\/plugins\/loftloader-pro\/(.*).js&#8221;<\/span> or <span class=\"highlighted\">&#8220;loftloader-pro\/(.*).js&#8221;<\/span>.\n<\/div>\n<hr>\n<h5>3. Exclude CSS files and inline CSS of LoftLoader<\/h5>\n<p>To ensure that LoftLoader works properly, you may also need to exclude the <strong>CSS files and inline CSS<\/strong> of LoftLoader.<\/p>\n<p><strong>Exclude styles (CSS files):<\/strong><\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px;\">\r\nloftloader.min.css\r\n<\/pre>\n<p>&nbsp;&nbsp;<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2020\/01\/exclude-style-file.png\" alt=\"\" width=\"519\" height=\"111\" class=\"alignnone size-full wp-image-518\" srcset=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2020\/01\/exclude-style-file.png 519w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2020\/01\/exclude-style-file-300x64.png 300w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/p>\n<div style=\"border: 1px solid #eee; background:#eee; padding: 50px;\"\">\nIf the cache plugin you are using supports the <strong>wildcard character<\/strong>, you can replace the above code with the following line of code. (In software, a wildcard character is a kind of placeholder represented by a single character, such as an asterisk (*), which can be interpreted as a number of literal characters or an empty string.)<\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px; margin-bottom: 30px;\">\r\nloftloader-pro\/(.*).css\r\n<\/pre>\n<\/div>\n<div class=\"info-box\" style=\"background: #FFF; border: 1px solid #DDD;padding: 30px;margin: 30px auto;\">\n<span class=\"highlighted\">Please note:<\/span> Different cache plugins may have different requirements for the path of the code filled in. In this document, we only indicate which CSS files of LoftLoader Pro need to be excluded. Please carefully read the documentation of the cache plugin you are using to make sure that the correct file path is filled. For example, <span class=\"highlighted\">&#8220;\/wp-content\/plugins\/loftloader-pro\/assets\/css\/loftloader.min.css&#8221;<\/span> or <span class=\"highlighted\">&#8220;loftloader-pro\/assets\/css\/loftloader.min.css&#8221;<\/span>, or even <span class=\"highlighted\">&#8220;loftloader.min.css&#8221;<\/span>.\n<\/div>\n<p><strong>Exclude inline styles<\/strong> (if the cache plugin provides this feature):<\/p>\n<pre style=\"border: 1px solid #eee; background:#fff; padding: 30px;\">\r\nloftloader-wrapper\r\n<\/pre>\n<p>&nbsp;&nbsp;<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2020\/01\/exclude-inline-style.png\" alt=\"\" width=\"519\" height=\"111\" class=\"alignnone size-full wp-image-519\" srcset=\"https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2020\/01\/exclude-inline-style.png 519w, https:\/\/loftocean.com\/doc\/loftloader\/wp-content\/uploads\/sites\/3\/2020\/01\/exclude-inline-style-300x64.png 300w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/p>\n<p>&#8211;<\/p>\n<p>Then, please always <strong>clear your site cache<\/strong> and <strong>browser cache<\/strong> after making changes, then refresh page and check again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If your website is using a cache\/performance optimization plugin, then it might combine\/minify JavaScript (or\/and CSS) and move them into the footer of your page. Then the preloader may not work properly. Because the JavaScript (and CSS) of LoftLoader needs to be put in the < head > of a page so it can be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":504,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-505","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/pages\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/comments?post=505"}],"version-history":[{"count":5,"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/pages\/505\/revisions"}],"predecessor-version":[{"id":678,"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/pages\/505\/revisions\/678"}],"up":[{"embeddable":true,"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/pages\/504"}],"wp:attachment":[{"href":"https:\/\/loftocean.com\/doc\/loftloader\/wp-json\/wp\/v2\/media?parent=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}