{"id":531,"date":"2024-06-26T11:26:35","date_gmt":"2024-06-26T11:26:35","guid":{"rendered":"https:\/\/faq.cinar-studio.ru\/?p=531"},"modified":"2024-06-26T11:26:35","modified_gmt":"2024-06-26T11:26:35","slug":"uskorenie-zagruzki-shrifta-za-schet-webfont-js","status":"publish","type":"post","link":"https:\/\/faq.cinar-studio.ru\/?p=531","title":{"rendered":"\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0448\u0440\u0438\u0444\u0442\u0430 \u0437\u0430 \u0441\u0447\u0435\u0442 Webfont.js"},"content":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0448\u0440\u0438\u0444\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 Webfont<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>functions.php<\/code> \u0432\u0430\u0448\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u0435\u043c\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p><code>function enqueue_web_font_loader() {<\/code><br \/>\n<code>wp_enqueue_script(<\/code><br \/>\n<code>'webfont-loader',<\/code><br \/>\n<code>'https:\/\/ajax.googleapis.com\/ajax\/libs\/webfont\/1.6.26\/webfont.js',<\/code><br \/>\n<code>array(),<\/code><br \/>\n<code>null,<\/code><br \/>\n<code>true<\/code><br \/>\n<code>);<\/code><\/p>\n<p><code>wp_add_inline_script('webfont-loader', '<\/code><br \/>\n<code>WebFont.load({<\/code><br \/>\n<code>google: {<\/code><br \/>\n<code>families: [\"Droid Serif\", \"Droid Sans\"]<\/code><br \/>\n<code>},<\/code><\/p>\n<p><code> active: function() {<\/code><br \/>\n<code>sessionStorage.fonts = true;<\/code><br \/>\n<code>}<\/code><br \/>\n<code>});<\/code><br \/>\n<code>');<\/code><br \/>\n<code>}<\/code><br \/>\n<code>add_action('wp_enqueue_scripts', 'enqueue_web_font_loader');<\/code><\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 Web Font Loader \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0448\u0440\u0438\u0444\u0442\u0430\u043c (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8220;Droid Serif&#8221; \u0438 &#8220;Droid Sans&#8221; \u043e\u0442 Google Fonts).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0448\u0440\u0438\u0444\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 Webfont \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b functions.php \u0432\u0430\u0448\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u0435\u043c\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430: function enqueue_web_font_loader() { wp_enqueue_script( &#8216;webfont-loader&#8217;, &#8216;https:\/\/ajax.googleapis.com\/ajax\/libs\/webfont\/1.6.26\/webfont.js&#8217;, array(), null, true ); wp_add_inline_script(&#8216;webfont-loader&#8217;, &#8216; WebFont.load({ google: { families: [&#8220;Droid Serif&#8221;, &#8220;Droid Sans&#8221;] }, active: function() { sessionStorage.fonts = true; } }); &#8216;); } add_action(&#8216;wp_enqueue_scripts&#8217;, &#8216;enqueue_web_font_loader&#8217;); \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 Web [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts\/531"}],"collection":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=531"}],"version-history":[{"count":1,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions"}],"predecessor-version":[{"id":532,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions\/532"}],"wp:attachment":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}