{"id":1157,"date":"2020-05-30T22:51:22","date_gmt":"2020-05-30T22:51:22","guid":{"rendered":"http:\/\/sp2hari.com\/?p=1157"},"modified":"2020-05-30T23:18:13","modified_gmt":"2020-05-30T23:18:13","slug":"improving-font-load-performance","status":"publish","type":"post","link":"https:\/\/sp2hari.com\/index.php\/2020\/05\/30\/improving-font-load-performance\/","title":{"rendered":"Improving font load performance"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This post is a result of an article I came across recently. <a href=\"https:\/\/csswizardry.com\/2020\/05\/the-fastest-google-fonts\/\">https:\/\/csswizardry.com\/2020\/05\/the-fastest-google-fonts\/<\/a>. This is a nice post which in detail about improving the performance of a website when loading fonts from Google. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is a lot of interesting items going on to make the web page load faster. <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>font-display: swap <br>Instructs the browser to use the fallback font to display the text until the custom font has fully downloaded. This is also known as a \u201cflash of unstyled text\u201d or FOUT<\/li><li>preload<br>The preload value of the <em>&lt;link&gt;<\/em> element&#8217;s <em>rel<\/em> attribute lets you declare fetch requests in the HTML&#8217;s <em>&lt;head&gt;<\/em>, specifying resources that your page will need very soon.<\/li><li>preconnect<br>The preconnect value of the <em>&lt;link&gt;<\/em> informs the browser that your page intends to establish a connection to another origin, and that you&#8217;d like the process to start as soon as possible.<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Of course, I wanted to see if this can help our home page load faster. The sample page to try this was the products page of hackerrank (<a href=\"https:\/\/www.hackerrank.com\/products\/\">https:\/\/www.hackerrank.com\/products\/<\/a>). To benchmark my results, I used <a href=\"https:\/\/www.webpagetest.org\/\">https:\/\/www.webpagetest.org\/<\/a> from Dulles, NA using Chrome with DSL internet speed. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These are the four different versions that were considered for this experiment. <\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table><thead><tr><th>Name<\/th><th>Details<\/th><\/tr><\/thead><tbody><tr><td>GoogleFont-V0<\/td><td>The base version which is the exact HTML copy of the HackerRank&#8217;s current webpage.<\/td><\/tr><tr><td>GoogleFont-V1<\/td><td>Removed an extra font-tag, which loads the same font OpenSans font again. <\/td><\/tr><tr><td>GoogleFont-V2<\/td><td>Added preload, print media swap, and merged the Open Sans and Source Code Pro in a single HTML tag at the head of the page. <\/td><\/tr><tr><td>GoogleFont-V4<\/td><td>Added preload, print media swap, and merged the Open Sans and Source Code Pro in a single HTML tag at the bottom of the page.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After all the experiment and measuring the web pages, the output was disappointing \ud83d\ude42<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube aligncenter wp-block-embed is-type-video is-provider-youtube\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Google Fonts Performance\" width=\"1249\" height=\"703\" src=\"https:\/\/www.youtube.com\/embed\/5Nugop7PGC0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Neither was there any change in the visual progress and overall timings. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"826\" height=\"518\" src=\"http:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.00-AM.png\" alt=\"\" class=\"wp-image-1158\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.00-AM.png 826w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.00-AM-300x188.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.00-AM-768x482.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.00-AM-478x300.png 478w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.00-AM-640x400.png 640w\" sizes=\"auto, (max-width: 826px) 100vw, 826px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"898\" height=\"483\" src=\"http:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.17-AM.png\" alt=\"\" class=\"wp-image-1159\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.17-AM.png 898w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.17-AM-300x161.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.17-AM-768x413.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/05\/Screenshot-2020-05-31-at-3.54.17-AM-558x300.png 558w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Like I mentioned earlier, I&#8217;m a little disappointed with the final result. I was hoping the font optimization will help a little bit. Running the same tests from the Singapore region resulted in the same results. The four different versions of the code we used for testing are available at <a href=\"https:\/\/github.com\/sp2hari\/google-fonts\">https:\/\/github.com\/sp2hari\/google-fonts<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is still a lot of scope for improvement. I see the first 4.5 seconds nothing really happening in the webpage and that&#8217;s something I plan to work on soon. The goal is to cut down the time to load by at least 1 second.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is a result of an article I came across recently. https:\/\/csswizardry.com\/2020\/05\/the-fastest-google-fonts\/. This is a nice post which in detail about improving the performance of a website when loading fonts from Google. There is a lot of interesting items going on to make the web page load faster. font-display: &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1157","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/1157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/comments?post=1157"}],"version-history":[{"count":11,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/1157\/revisions"}],"predecessor-version":[{"id":1174,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/1157\/revisions\/1174"}],"wp:attachment":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/media?parent=1157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/categories?post=1157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/tags?post=1157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}