{"id":26305,"date":"2016-04-06T21:01:39","date_gmt":"2016-04-06T13:01:39","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=26305"},"modified":"2022-07-15T17:06:44","modified_gmt":"2022-07-15T09:06:44","slug":"writing-better-css","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/","title":{"rendered":"How to Write Better CSS with Performance in Mind"},"content":{"rendered":"<p class=\"note\"><strong>Editor\u2019s note: <\/strong>This article is part of our <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/tag\/code-optimization-series\/\" rel=\"noopener\">Code Optimization series<\/a>, where we take a look at how to optimize coding for better efficiency in a bid to be better coders.<\/p>\n<p>In today\u2019s post we will ponder over the code choices we can make in CSS for improved site performance. But, before we dive into those choices, let\u2019s first take a brief, closer look at the webpage <a target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Tools\/Performance\/Waterfall#Rendering_waterfall\" rel=\"noopener\">rendering workflow<\/a> in order to focus on the<em> <\/em>problematic (performance-wise) areas that are solvable via CSS.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg\" alt=\"Browser Rendering Workflow\" width=\"1046\" height=\"118\"><\/figure>\n<p>Here\u2019s the rough flow of operations performed by the browser after DOM tree creation:<\/p>\n<ol>\n<li><strong>Recalculate Style (and render tree creation). <\/strong>Browser computes the styles to be applied to the elements in the DOM tree. A render tree is later created while discarding the nodes (elements) from the DOM tree that aren\u2019t to be rendered (elements with <code>display:none<\/code>) and those that are (pseudo-elements).<\/li>\n<li><strong>Layout (aka Reflow). <\/strong>Using the computed style from before, the browser calculates the position and geometry of each element on the page.<\/li>\n<li><strong>Repaint. <\/strong>Once the layout is mapped, pixels are drawn to the screen.<\/li>\n<li><strong>Composite Layers. <\/strong>During repainting, the painting might be done in different layers autonomously; those layers are then finally combined together.<\/li>\n<\/ol>\n<p>Now let\u2019s continue on to what we can do in the first three stages of the operation to write better-performing CSS codes.<\/p>\n<h2>1. Reduce Style Calculations<\/h2>\n<p>Like mentioned before, in the \"Recalculate Style\" stage the browser computes the styles to be applied to the elements. To do this, the browser first finds out all the selectors in the CSS that point to a given element node in the DOM tree. Then it goes through all the style rules in those selectors and decides which ones are to be actually applied to the element.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/style-calc.jpg\" alt=\"Style Calc\" width=\"567\" height=\"320\"><figcaption class=\"entry-image-caption\"><a target=\"_blank\" href=\"https:\/\/aerotwist.com\/\" rel=\"noopener\">IMAGE: Aerotwist<\/a><\/figcaption><\/figure>\n<p>To avoid costly style calculations, <strong>reduce complex and deeply nested selectors<\/strong> so that it\u2019s easier for the browser to figure out which element a selector is referring to. This reduces computational time.<\/p>\n<p>Other ways to employ include <strong>reducing the number of style rules<\/strong> (where possible), <strong>removing unused CSS<\/strong> and avoiding <strong>redundancy & overrides<\/strong>, so that the browser doesn\u2019t have to go through the same style again and again during style calculations.<\/p>\n<p class=\"note\"><strong>Tip:<\/strong> To reduce style calculation cost, a reduction in DOM tree size is as equally effective as the reduction of style rules.<\/p>\n<h2>2. Reduce Reflows<\/h2>\n<p>Reflows or Layout changes in an element are very \"expensive\" processes, and they can be of an even bigger problem when the element that went through the layout changes has a significant amount of children (since <strong>Reflows cascade down the hierarchy<\/strong>).<\/p>\n<p class=\"note\"><em>\u201cAt Google, we test the speed of our web pages and applications in a variety of ways \u2013 and reflow is a key factor we consider when adding features to our UIs.\u201d \u2013 <a target=\"_blank\" href=\"https:\/\/developers.google.com\/speed\/docs\/insights\/browser-reflow\" rel=\"noopener\">Google Developers<\/a><\/em><\/p>\n<p>Reflows are triggered by layout changes to an element, like changes to the geometric properties such as height or font size, the addition or removal of classes to elements, window resizing, activated <code>:hover<\/code>, DOM changes by JavaScript, etc.<\/p>\n<p>Just like in style calculation, to reduce Reflows, <strong>avoid complex selectors <\/strong>and<strong> deep DOM trees<\/strong> (again, this is to prevent excessive cascading of Reflows).<\/p>\n<p>If you have to change the layout styles of a component in your page, <strong>target the styles of the element that is at the lowest in the hierarchy of elements<\/strong> that the component is made of. This is so that the layout changes doesn\u2019t trigger (almost) any other Reflows.<\/p>\n<p>If you\u2019re animating an element that goes through layout changes, <strong>take it out of the page flow <\/strong>by<strong> absoutely positioning it<\/strong>, since Reflow in absolutely positioned elements won\u2019t affect the rest of the elements on the page.<\/p>\n<p><strong>To summarise:<\/strong><\/p>\n<ul>\n<li> Target elements that are lower in the DOM tree when making layout changes<\/li>\n<li>Choose absolutely positioned elements for layout changing animations <\/li>\n<li> Avoid animating layout properties whenever possible<\/li>\n<\/ul>\n<h2>3. Reduce Repaints<\/h2>\n<p>Repaint refers to the drawing of pixels on the screen, and is an expensive process just like Reflow. Repaints can be triggered by Reflows, page scroll, changes in properties like color, visibility and opacity.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/pixel-art.jpg\" alt=\"Pixel Art\" width=\"800\" height=\"428\"><\/figure>\n<p class=\"note\"><em>\u201cSome paint effects, such as box-shadow, can be expensive, especially if you are applying them in a transition where the browser has to calculate them in every frame.\u201d \u2013 <a target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Tools\/Performance\/Waterfall#Expensive_paints\" rel=\"noopener\">Mozilla Developer Network<\/a><\/em><\/p>\n<p>To avoid frequent and huge repaints, <strong>use less of the properties that cause costly repaints <\/strong>like shadows.<\/p>\n<p>If you\u2019re animating properties of an element that can trigger Repaint directly or indirectly, it\u2019ll be of great advantage <strong>if that element is in its own layer<\/strong> preventing its painting prcoess from affecting the rest of the page and triggering hardware acceleration. In hardware accelaration, the GPU will take up the task of performing the animation changes in the layer, saving the CPU extra work while speeding up the process.<\/p>\n<p class=\"note\"><em>\u201cIn a nutshell, Hardware Acceleration means that the Graphics Processing Unit (GPU) will assist your browser in rendering a page by doing some of the heavy lifting, instead of throwing it all onto the Central Processing Unit (CPU) to do.\u201d \u2013 <a target=\"_blank\" href=\"https:\/\/sarasoueidan.com\/index.html\" rel=\"noopener\">Sara Soueidan<\/a><\/em><\/p>\n<p>In some browsers, <code>opacity<\/code> (with a value of less than <code>1<\/code>) and <code>transform<\/code> (value other than <code>none<\/code>) are automatically promoted to new layers, and hardware acceleration is applied for animations and transitions. Preferring these properties for animations is thusly good.<\/p>\n<p>To forcefully <strong>promote an element to new layer and go into hardware acceleration<\/strong> for animation, there are two techniques invovled:<\/p>\n<ol>\n<li> add <code>transform: translate3d(0, 0, 0);<\/code> to the element, tricking the browser into triggering the hardware acceleration for animations and transitions.<\/li>\n<li>add the <code>will-change<\/code> property to the element, which informs the browser of the properties that are likely to change in the element in the future. <strong>Note<\/strong>: Sara Soueidan has an in-depth and super-helpful <a target=\"_blank\" href=\"https:\/\/dev.opera.com\/articles\/css-will-change-property\/\" rel=\"noopener\">article<\/a> on this in the Dev.Opera site.<\/li>\n<\/ol>\n<p>To summarise:<\/p>\n<ul>\n<li>Avoid expensive styles that cause Repaints<\/li>\n<li> Seek layer promotion and hardware acceleration for hefty animations and transitions.<\/li>\n<\/ul>\n<h2>Take Note<\/h2>\n<p>(1) So up til now, we haven\u2019t touched on CSS file size reduction. We have mentioned that reduction in style rules (and DOM elements) make a significant performance improvement because of <strong>how much the browser will have to work <em>less<\/em> on the process of computing the styles<\/strong>. As a consequence of this code reduction, writing better selectors and the deletion of unused CSS, <strong>the file size will automatically decrease<\/strong>.<\/p>\n<p>(2) It\u2019s also advisable to <strong>not make too many consequential changes to an element\u2019s styles in JavaScript<\/strong>. Instead add a class to the element (using JavaScript) that holds the new styles to make these changes \u2013 this prevents unnecessary Reflows.<\/p>\n<p>(3) You will want to <strong>avoid Layout Thrashing<\/strong> as well (forced synchronous Reflows) which arises due to the accessing and modifying of the Layout properties of elements using JavaScript. Read more about how this kills performance <a target=\"_blank\" href=\"http:\/\/blog.wilsonpage.co.uk\/preventing-layout-thrashing\/\" rel=\"noopener\">here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Editor\u2019s note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be better coders. In today\u2019s post we will ponder over the code choices we can make in CSS for improved site performance. But, before we dive into&hellip;<\/p>\n","protected":false},"author":145,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[3427,507,4501,3761],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Write Better CSS with Performance in Mind - Hongkiat<\/title>\n<meta name=\"description\" content=\"Editor&#039;s note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Write Better CSS with Performance in Mind\" \/>\n<meta property=\"og:description\" content=\"Editor&#039;s note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-06T13:01:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-15T09:06:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg\" \/>\n<meta name=\"author\" content=\"Preethi Ranjit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Preethi Ranjit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/\"},\"author\":{\"name\":\"Preethi Ranjit\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\"},\"headline\":\"How to Write Better CSS with Performance in Mind\",\"datePublished\":\"2016-04-06T13:01:39+00:00\",\"dateModified\":\"2022-07-15T09:06:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/\"},\"wordCount\":1126,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/writing-better-css\\\/browser-rendering-workflow.jpg\",\"keywords\":[\"Code Optimization\",\"CSS\",\"CSS Tutorials\",\"Series: Code Optimization\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/\",\"name\":\"How to Write Better CSS with Performance in Mind - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/writing-better-css\\\/browser-rendering-workflow.jpg\",\"datePublished\":\"2016-04-06T13:01:39+00:00\",\"dateModified\":\"2022-07-15T09:06:44+00:00\",\"description\":\"Editor's note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/writing-better-css\\\/browser-rendering-workflow.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/writing-better-css\\\/browser-rendering-workflow.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/writing-better-css\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Write Better CSS with Performance in Mind\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\",\"name\":\"Preethi Ranjit\",\"description\":\"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/preethi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Write Better CSS with Performance in Mind - Hongkiat","description":"Editor's note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/","og_locale":"en_US","og_type":"article","og_title":"How to Write Better CSS with Performance in Mind","og_description":"Editor's note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be","og_url":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2016-04-06T13:01:39+00:00","article_modified_time":"2022-07-15T09:06:44+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg","type":"","width":"","height":""}],"author":"Preethi Ranjit","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Preethi Ranjit","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/"},"author":{"name":"Preethi Ranjit","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3"},"headline":"How to Write Better CSS with Performance in Mind","datePublished":"2016-04-06T13:01:39+00:00","dateModified":"2022-07-15T09:06:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/"},"wordCount":1126,"commentCount":7,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg","keywords":["Code Optimization","CSS","CSS Tutorials","Series: Code Optimization"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/","url":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/","name":"How to Write Better CSS with Performance in Mind - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg","datePublished":"2016-04-06T13:01:39+00:00","dateModified":"2022-07-15T09:06:44+00:00","description":"Editor's note: This article is part of our Code Optimization series, where we take a look at how to optimize coding for better efficiency in a bid to be","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/writing-better-css\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/writing-better-css\/browser-rendering-workflow.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/writing-better-css\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Write Better CSS with Performance in Mind"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3","name":"Preethi Ranjit","description":"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.","url":"https:\/\/www.hongkiat.com\/blog\/author\/preethi\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-6Qh","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/26305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/145"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=26305"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/26305\/revisions"}],"predecessor-version":[{"id":60465,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/26305\/revisions\/60465"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=26305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=26305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=26305"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=26305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}