<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ankur Jain on Medium]]></title>
        <description><![CDATA[Stories by Ankur Jain on Medium]]></description>
        <link>https://medium.com/@ankur.jain9292?source=rss-502c3dddad01------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*N4ODhNKp8Gm9PYPCoEBR5w.png</url>
            <title>Stories by Ankur Jain on Medium</title>
            <link>https://medium.com/@ankur.jain9292?source=rss-502c3dddad01------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:09:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankur.jain9292/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Measure UI/Page Load Time in Production]]></title>
            <link>https://medium.com/@ankur.jain9292/how-to-measure-ui-page-load-time-in-production-30bb8affafcb?source=rss-502c3dddad01------2</link>
            <guid isPermaLink="false">https://medium.com/p/30bb8affafcb</guid>
            <category><![CDATA[website-performance]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ui-performance]]></category>
            <category><![CDATA[browser-performance]]></category>
            <category><![CDATA[client-side-rendering]]></category>
            <dc:creator><![CDATA[Ankur Jain]]></dc:creator>
            <pubDate>Sun, 12 Jan 2020 08:03:36 GMT</pubDate>
            <atom:updated>2020-01-12T08:03:36.718Z</atom:updated>
            <content:encoded><![CDATA[<p>With new technologies, techniques and tools coming up almost every other day, websites are becoming more complex day by day. Everyone wants their website to stand out among their competitors with high resolution graphics, heavy animations and aesthetic design. All these graphic-intense requirements have made it a daunting task for website developers to keep page load times under the benchmark of 3 seconds. I agree that there are multiple good tools like Google PageSpeed, Yslow, WebPageTest, etc., available in the market to help in improving the webpage performance and getting the desired Page Load Time, but still, when it comes to an actual end user, there are a few questions that are largely unanswered:</p><p>· How much time does my webpage take to load for an actual end user in production?</p><p>· How can we measure the rendering time of our end users? Are there any tools for this?</p><p>· Does getting production rendering time cause any overhead?</p><p>· And of course, cost associated in getting these production numbers. Is it feasible?</p><p>Most of the questions related to page rendering time are answered by running our tests on a simulated production-like environment, or sometimes on an actual production website. Although these are perfectly fine ways to get some numbers to start with, are they enough to give us all the answers, or can we fully rely on these numbers to know the end user experience? When millions of users all over the world use your website, you cannot simulate all the scenarios under which the website is being accessed. Here are a few conditions that might impact the Page Load time for an end user:</p><p>· Internet speed</p><p>· Browser type and its version</p><p>· Machine configurations (RAM, CPU etc.)</p><p>· Mobile or desktop user</p><p>· Distance of end user from our servers, latency</p><p>· Firewalls, etc.</p><p>Simulating and testing your website against all these conditions incurs a lot of man hours — and you still might not be able to cover everything. Now you may be thinking that the solution to this problem is cumbersome and requires some expensive tweaking. The solution is actually just one line of code. Yes, you read it correctly <strong>JUST ONE LINE!!</strong></p><p>Let me introduce you to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark"><strong>performance.mark()</strong></a>, which is a part of <a href="https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API"><strong>User Timing API</strong></a> and arguably the most useful performance measuring method in our browser to create application-related timestamps that are part of browser’s performance timeline. These markers, when combined with deep understanding of how browsers work, can become quite useful in answering most of our questions related to webpage load times. We can inline these markers directly into our HTML code using one-liner JS:</p><blockquote>&lt;script&gt; performance.mark(&quot;Image loaded&quot;); &lt;/script&gt;</blockquote><p>These markers can be added to any location of our document, thus marking the time it took our browser to reach that line of code in our document. Let’s try it out!</p><p>I wrote a website for my <strong>CAT</strong>, because WHY NOT?! Look at this simple code snippet:</p><blockquote><em>&lt;html&gt;</em></blockquote><blockquote><em>&lt;head&gt;</em></blockquote><blockquote><em>&lt;title&gt;Performance marks Demo&lt;/title&gt;</em></blockquote><blockquote><em>&lt;script&gt;performance.mark(‘parsing:css:start’);&lt;/script&gt;</em></blockquote><blockquote><em>&lt;link rel=”stylesheet” href=”style.css”&gt;</em></blockquote><blockquote><em>&lt;script&gt;</em></blockquote><blockquote><em>performance.mark(‘parsing:css:end’);</em></blockquote><blockquote><em>performance.measure(‘blocking-styles’, ‘parsing:css:start’, ‘parsing:css:end’);</em></blockquote><blockquote><em>&lt;/script&gt;</em></blockquote><blockquote><em>&lt;/head&gt;</em></blockquote><blockquote><em>&lt;body&gt;</em></blockquote><blockquote><em>&lt;p&gt;What a beautiful cat&lt;/p&gt;</em></blockquote><blockquote><em>&lt;img src=”Cat.jpg” alt=”cat”&gt;</em></blockquote><blockquote><em>&lt;/body&gt;</em></blockquote><blockquote><em>&lt;/html&gt;</em></blockquote><p>In the above code, you can see another method is added.</p><blockquote><em>performance.measure(‘blocking-styles’, ‘parsing:css:start’, ‘parsing:css:end’);</em></blockquote><p>Performance.measure() gives the distance between the two marks, thus relieving us from calculating the time taken to download, parse and apply the above CSS. These measurements can be <a href="https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API#Retrieving_performance_measures">retrieved</a> easily by using one of the three methods of performance interface. Let’s see how much time it took for our CSS to download, parse and apply by using <em>performance.getEntriesByType(“measure”)</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*D1HDWtRgaeDYR4dbqnKN3A.png" /></figure><p>If you see carefully, my website is basically just an image of my beloved cat<strong>. </strong>So, it makes sense for me to understand when this image gets downloaded and loaded into my web page. These images are known as <strong>HERO</strong> elements, and are of utmost importance to the end users. All the <strong>HERO</strong> elements can be identified by the developer and marked easily. Let’s tweak my above code to add this Hero element and see the results.</p><blockquote><em>&lt;img src=”Cat.jpg” alt=”cat” onload=”performance.mark(‘img displayed’);”&gt;</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*xpI1d6nKOS98Cd9BJMGgzg.png" /></figure><p>Now the last piece of the puzzle is to retrieve this information from the end user browser. One of the easiest ways to do this is by writing a light weight JS that will fetch these measurements and send it to our server. This JS can be called at the end of your webpage when the whole page has been parsed. Thus, fetching the measurements does not incur any performance bottlenecks for the end user.</p><p>One of the practical examples of this is <a href="http://www.optimizely.com/">Optimizely</a>, which has embedded marks throughout their client JS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*gWMzxk4TSk_yxqLzeFrXEQ.png" /></figure><p>The solution to the most important and common question “<strong><em>How much time does my webpage take to load!!</em></strong>” was always there, but somehow we all missed implementing it into our application. Moreover, the data fetched from the above solution can be analyzed in a number of ways and can give us some interesting insight about our application from the end-user perspective. I leave that for you to find out!</p><p><strong><em>Give it a try and share your experience in the comment section below!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30bb8affafcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>