<?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 Emre Yasin Çolakoğlu on Medium]]></title>
        <description><![CDATA[Stories by Emre Yasin Çolakoğlu on Medium]]></description>
        <link>https://medium.com/@emreyc?source=rss-c23c0c2eead3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JfQY7xYGpHht-GbCKIC4Pw.jpeg</url>
            <title>Stories by Emre Yasin Çolakoğlu on Medium</title>
            <link>https://medium.com/@emreyc?source=rss-c23c0c2eead3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:20:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emreyc/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[Code Reusability and Scalability in Web Projects]]></title>
            <link>https://medium.com/kunduzinc/code-reusability-and-scalability-in-web-projects-ab8ed39bc60d?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab8ed39bc60d</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[nx]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Mon, 22 Aug 2022 12:55:13 GMT</pubDate>
            <atom:updated>2022-08-22T12:55:13.149Z</atom:updated>
            <content:encoded><![CDATA[<p>Making the code <strong>accessible</strong>, <strong>reusable</strong> and <strong>scalable</strong> in an <strong>organized</strong> fashion not only benefits your <strong>current</strong> project but also your <strong>future</strong> projects. You can easily <strong>pick up</strong> from where you left off, <strong>bootstrap</strong> new projects with ease, <strong>decrease</strong> code maintenance costs, have a <strong>simpler</strong> mental model and <strong>onboard</strong> new members more effectively. 📈</p><p>We recently <strong>improved</strong> how we tackled these concepts in <strong>Kunduz</strong> and we’d like to share our findings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PtgW_xIKCn444Pa8" /></figure><h3>Problems</h3><h4>Amount of projects</h4><p>For a long time, as a <strong>growing</strong> startup, our motto was to “Move fast &amp; break things” 💥. <strong>Non-critical</strong> bugs were not a show stopper. We were able to publish bug fixes quickly. That mentality is also reflected in the <strong>number</strong> of projects we created. Instead of having a <strong>monolith</strong> as a project for different <strong>stakeholders</strong> of our product, we <strong>divided</strong> and <strong>conquered</strong>. We created <strong>separate mini websites </strong>for our students, tutors, annotators, ML matchers, and our corporate identity. 📦</p><p>This allowed us to <strong>iterate</strong> fast and find <strong>product-market fit</strong> more quickly, but as the products and features <strong>matured</strong>, a more <strong>integrated</strong> experience was needed to provide <strong>value</strong>. And our way of working <strong>didn’t</strong> provide that. ⚠️</p><h4>Project tree complexity</h4><p>While there are <strong>opinionated</strong> best practices about how to organize projects, libraries, components, and code in general, our main development tool, <strong>React</strong>, doesn’t really impose anything. You can have gigantic <strong>mono-components</strong> or thousands of <strong>mini components</strong>, use <strong>context</strong> api, <strong>swr</strong> or <strong>mobx</strong> variants for data &amp; state management, <strong>classes</strong>, hooks, <strong>typescript</strong>, enzyme or <strong>testing library</strong> etc. anything.</p><p>And having that many <strong>aspects</strong> of a feature in the same place increases the number of files in the project <strong>tree</strong>. It increases the <strong>cognitive workload</strong> of the developers. It causes <strong>mistakes</strong>. It <strong>slows the onboarding </strong>process of new hires. It creates <strong>configuration problems </strong>between tools. ⚙️</p><h4>Code complexity</h4><p>Remember when I said React doesn’t empose anything? We took full advantage of that. We had components that retrieved its <strong>own</strong> <strong>data</strong>, displayed its own <strong>skeleton UI</strong>, implemented its own <strong>business logic</strong>, had its own <strong>analytics codes</strong>, and had <strong>specific styles</strong> for a <strong>specific position</strong> on the page its being used. 🎨</p><p>While it created some <strong>beautifully outrageous</strong> components &amp; libraries and increased the development pace <strong>spectacularly</strong>, it never fully allowed us to <strong>reuse</strong> that component. This brings us to:</p><h4>Code Reusability</h4><p>Well, what did we learn about <strong>functions</strong> in college?<br>“A function is simply a “chunk” of code that you can use over and over again, rather than writing it out <strong>multiple</strong> times.”</p><p>It’s like that but on a <strong>whole project</strong> level. Development time is a <strong>finite</strong> resource. We need to be <strong>smart</strong> about <strong>what</strong> code we write or <strong>how</strong> we write it to keep up with the sprint <strong>timeline</strong>, decrease the amount of code to <strong>maintain,</strong> or just increase the <strong>efficiency</strong>. 📦</p><p>We had <strong>multiple</strong> projects with <strong>separate</strong> git repositories. Some of them depended on the<strong> same designs</strong>. Some of them had <strong>identical</strong> features (auth). Some of them needed to access other project <strong>resources</strong>.</p><h3>Failed Attempts — Monorepo</h3><p>Monorepos are awesome. You can have multiple projects in the same repository and access any of them anytime. Or so we thought.</p><p>If you dive into a monorepo setup <strong>head-first</strong> without thinking about how to <strong>organize</strong> your code in a shareable fashion, you are going to have a <strong>bad time</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*gsH5KsyCz3s0QZtpSnjSqw.jpeg" /></figure><p>By the time we first tested our monorepo solution, we had already merged different <strong>mini projects</strong> into a <strong>monolith</strong>. So we only had one deployable “<strong>app</strong>”. This made potential problems harder to find. When our one app was <strong>working</strong> fine, we thought <em>“this is it, we freakin’ did it”</em>. We didn’t have any reason to think <strong>otherwise</strong>. 😇</p><p>These all came crumbling down when I <strong>introduced</strong> another app to our monorepo. There were many problems with <strong>importing</strong> shared code, teaching <strong>typescript</strong> compiler the correct file paths, making sure <strong>testing</strong> and <strong>ui tools</strong> play nice with new setup, building the <strong>correct</strong> project, and not breaking our <strong>existing</strong> project in the process. 😈</p><p>There was something wrong with our solution. There had to be a better way to do this. Someone out there must have figured out how to do this better than we did.</p><p>And they did!</p><h3>Introducing: NX</h3><p>By their definition, <strong>Nx</strong> is “Next generation build system with first-class monorepo support and powerful integrations.” This definition doesn’t do the tool justice. Nx <strong>completely</strong> abstracts the configuration phase of a monorepo. Things just work. Creating <strong>workspaces</strong>, <strong>projects</strong>, <strong>libraries</strong>, and <strong>components</strong> is a breeze. You have total control and freedom. 🏳</p><p>The official Nx plugin ecosystem is quite large and includes the best in the business. <strong>React</strong>, <strong>React Native</strong>, <strong>Next.js</strong>, <strong>Storybook</strong>, <strong>Cypress</strong>, <strong>Node</strong>, <strong>Express</strong> and more. They seamlessly work with each other and are contained in a single package.json file. No more “My newly created UI library uses React 18 but my legacy app has 17” problems. <strong>Unit</strong> and <strong>e2e</strong> testing infrastructure is created for you. No more “yeah, we didn’t have any time to write tests in this sprint” as an excuse. It’s right there. They magically work well together.</p><p>But enough promotion, let&#39;s talk shop;</p><p>To create a new workspace with nx, just run</p><pre>npx create-nx-workspace@latest</pre><p>It will ask you for a <strong>preset</strong>, and some options as well. If you have something <strong>specific</strong> in mind, you can also run</p><pre># create an empty workspace set up for building applications<br>npx create-nx-workspace --preset=apps<br><br># create an empty workspace set up for building packages<br>npx create-nx-workspace --preset=core<br><br># create an empty workspace set up for building packages with the @nrwl/js plugin installed<br>npx create-nx-workspace --preset=ts</pre><p>The folder structure is like below, and I must say it&#39;s pretty much <strong>standard</strong> at this point. What makes Nx special is you can give <strong>tags</strong> to your individual projects and decide who can depend on whom. <a href="https://nx.dev/structure/monorepo-tags">See here</a></p><pre>myorg/<br>├── apps/<br>├── libs/<br>├── tools/<br>├── workspace.json<br>├── nx.json<br>├── package.json<br>└── tsconfig.base.json</pre><p>Another <strong>useful</strong> trick is the -affected option. With this, Nx only runs tests on <strong>changed</strong> code.</p><pre>nx affected --target=test</pre><p>This will tell Nx to figure out what changed, what those <strong>changes</strong> depend on, and only run tests on affected areas. This <strong>saves</strong> development and CI time.</p><p>Nx supports many <strong>tools</strong> &amp; <strong>technologies</strong>. You can go pretty far with the official packages <a href="https://nx.dev/packages">listed here</a> or <a href="https://nx.dev/community#plugin-directory">you can check out the community plugins</a></p><p><a href="https://nx.dev/packages">Reference: Official Packages &amp; API</a></p><p>One of its most advertised features is its <strong>cache</strong> system. With this, Nx promises it never runs the <strong>same</strong> computation <strong>twice</strong>. If you didn’t change your code and tried to build again, it’s near <strong>instant</strong>. This feature is not limited to build outputs though. It supports <strong>test results</strong> as well. Combined with the -affected option, Nx helps developers and projects save time. 💪</p><p>We recently migrated our monorepo codebase to Nx and started to refactor our features under /libs/feature-* packages. It will allow us to share code more effectively and contain related business logic in the same space. While doing that, all the data access infrastructure got moved under /libs/data-access-* packages and all shared ui code got moved under /libs/ui-* packages.</p><p>For example, with the development of <a href="https://nextjs.org/blog/layouts-rfc">Next.js Layout RFC</a> the layout structure of a typical Next.js project will change and pages will have special logics. <strong>Migrating</strong> our features to bite-sized individual <strong>packages</strong> will allow us to do required Next.js changes without moving many files around. And that will lead to <strong>fewer bugs</strong>, mistakes, and effort all around.</p><p>We really liked what this tool offered and hope to have a scalable and accessible project structure for many years to come. If you also enjoyed reading and want to be a part of our team, you can <a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d"><strong>click this link</strong></a> and reach out to us.</p><p><a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d">Kunduz wants to meet you!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab8ed39bc60d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kunduzinc/code-reusability-and-scalability-in-web-projects-ab8ed39bc60d">Code Reusability and Scalability in Web Projects</a> was originally published in <a href="https://medium.com/kunduzinc">Kunduz, Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Headless Wordpress with NextJs]]></title>
            <link>https://medium.com/kunduzinc/using-headless-wordpress-with-nextjs-3eab760f0433?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3eab760f0433</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 10:19:17 GMT</pubDate>
            <atom:updated>2022-08-15T08:20:37.130Z</atom:updated>
            <content:encoded><![CDATA[<p>During the course of a startup’s life, your expectations from the website will change. While at early stages simply <strong>being online</strong> would suffice, it is expected that this channel will develop in the future and bring you <strong>new users</strong>.</p><p>And with this change in requirements, we must also take a look at <strong>what tools</strong> we use and <strong>how </strong>we might use them. Here at <strong>Kunduz</strong>, we are using <strong>Wordpress </strong>as our website solution for more than 3 years now. But lately it just wasn’t enough.</p><p>When we first built our website in 2018 our requirements were <strong>just </strong>to be able to be <strong>Googled</strong>. We had practically <strong>no content</strong>, only <strong>one landing page</strong> which was the homepage and <strong>a plans page</strong> where we displayed our products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*N88Q7hhploNz9GcFoMtFcw.jpeg" /><figcaption>Kunduz circa 2018</figcaption></figure><p>When 2019 came our <strong>requirements</strong> were very different. We wanted <strong>our content editors</strong> and various employees to be able to publish static pages <strong>without </strong>the help of a <strong>developer</strong>. Our newly started blog was doing quite well. But we didn’t have <strong>anything else</strong> to offer to our users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZtN2Qo5Hdw7cqqpkFHBaQ.png" /><figcaption>Kunduz (now)</figcaption></figure><p>During the <strong>pandemic </strong>we built various products and features for our users. But some developments were made to increase our reach in <strong>Google </strong>search results as well. One of them was our question indexing websites. We indexed a portion of our questions to <strong>attract </strong>more users. Now we had another <strong>type of content</strong> served from our websites aside from blog posts. Naturally, we wanted to show <strong>related </strong>content on those pages. 🕸️</p><p>Wouldn’t it be nice if you could see some <strong>already </strong>answered questions about the <strong>subject </strong>you are reading about? Or a series of <strong>videos </strong>explaining that particular subject? That’s what we wanted to build.</p><p><a href="https://medium.com/kunduzinc/how-to-publish-amazing-landing-pages-a820918c8a49">How to Publish Amazing Landing Pages?</a></p><p>However, actually doing this was a challenge. <strong>None</strong> of our developers (including yours truly) <strong>knew </strong>PHP or <strong>wanted </strong>to learn PHP. We were fine with creating a template for <strong>Wordpress </strong>but anything more than that was off the limits. That’s why we failed to implement <strong>necessary </strong>changes to design a more <strong>streamlined </strong>experience for our users. ❌</p><p>We researched <strong>different</strong> tools to address these issues. We evaluated platforms like <strong>Webflow</strong>, <strong>Ghost</strong>, <strong>Strapi </strong>etc but none of them could single-handedly solve all our problems. They were either too <strong>primitive </strong>or too <strong>complicated </strong>for our use-cases. We also considered the migration process of our existing <strong>1000+</strong> pages of content and the <strong>education </strong>period of our editors.</p><p>When we realized that we couldn’t solve this solution with a <strong>third party</strong> tool, we decided to build our <strong>own </strong>solution.</p><h3>Enter: Wordpress as Headless CMS</h3><p>To fix all of the problems I mentioned, we decided to use <strong>Wordpress </strong>as a <strong>headless CMS</strong> and use <strong>NextJs </strong>as the presentation layer. This way we could</p><ul><li>Develop with a <strong>language </strong>we were already fluent in</li><li>Have more <strong>integration </strong>options</li><li>Not lose (or have to migrate) 3 years worth of <strong>content</strong></li><li>Not lose site editors <strong>know-how</strong></li></ul><p>While searching through the internet for examples and articles from developers who walked on this path before me, I stumbled upon an example from the <strong>NextJs </strong>team. The <strong>“Wordpress &amp; GraphQL &amp; NextJs”</strong> hybrid.</p><p><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-wordpress">next.js/examples/cms-wordpress at canary · vercel/next.js</a></p><p>This immediately gave me a<strong> lightbulb </strong>moment and <strong>answered </strong>the most deeply buried, <strong>dreaded </strong>question there ever is. How to deal with <strong>nested data</strong>? Unlike traditional <strong>REST</strong>, with <strong>GraphQL</strong>, you can request relationship data in the same request. With <strong>REST</strong>, this would have to be N amount of requests depending on the <strong>relationship </strong>count. And believe me there are lots of <strong>relations </strong>in a traditional blog post. <strong>Author</strong>, <strong>category</strong>, <strong>seo meta</strong>, <strong>tags</strong>, <strong>main image</strong> to name a few. 💡</p><h4>Installing GraphQL plugins</h4><p>The first order of business was to install the necessary <strong>GraphQL </strong>plugins so that development could begin. The <strong>wonderful </strong>GraphQL team made everything very straightforward and installation was a breeze. 🙏</p><p><a href="https://www.wpgraphql.com/">GraphQL API for</a></p><p>After installing the common plugin extensions like <strong>Yoast Seo</strong>, <strong>Advanced Custom Fields</strong> and <strong>Custom Post Types</strong>, we were ready to go.</p><h4>Migrating from WPML to PolyLang</h4><p>Kunduz.com is a <strong>multilanguage</strong> website. We used a translation and localization plugin called <strong>WPML </strong>for three years without any issues. But sadly it was not allowing us to query with <strong>language </strong>data when requesting blogs posts or pages. For example, we were <strong>not </strong>able to query for the most recent 20 blog posts published for <strong>Turkey</strong>. That’s why we migrated our localization solution to another Wordpress plugin called <strong>PolyLang</strong>. PolyLang both offered a <strong>migration tool</strong> and <strong>GraphQL plugin</strong> and it was the natural selection for us. During the migration process we still needed to patch here and there, mainly with pages sharing <strong>the same slug</strong> for different locales. Overall, the migration was done <strong>without any hiccups</strong>.</p><p><a href="https://polylang.pro/">Polylang - Making WordPress multilingual</a></p><h4>Bootstrapping the NextJs Project</h4><p>After the <strong>Wordpress </strong>part was done, we started the development of the <strong>NextJs </strong>project. Since there were only three major responsibilities of <strong>Wordpress </strong>we proceeded quickly. At the very basic level, <strong>NextJs </strong>had to</p><ul><li>Display a <strong>static </strong>page</li><li>Display the <strong>list of blog posts</strong></li><li>Display a <strong>single blog post</strong></li></ul><p>During the development, we noticed some <strong>architectural decisions</strong> to make about the data fetching. We could just create <strong>a new axios instance</strong> and request data from <strong>Wordpress </strong>endpoint in our <strong>getServerSideProps </strong>function. But this wasn’t the right way and this would <strong>never </strong>scale. 📈</p><p>So, with the help of the handy <strong>next-connect</strong> package, we started to collect these functions into <strong>middlewares</strong>. This way, all common <strong>initialization </strong>logic like <strong>authentication</strong>, <strong>error handling</strong> and <strong>custom headers</strong> could be shared among functions.</p><p>When done, we had 5 middlewares;</p><ul><li><strong>Elastic </strong>Middleware</li><li><strong>Kunduz Api</strong> Middleware</li><li><strong>Wordpress </strong>Middleware</li><li><strong>Session </strong>Middleware</li><li><strong>Cache </strong>Middleware</li></ul><p>The names are pretty self explanatory. We use different <strong>backends </strong>to store <strong>different </strong>types of content. 🏦</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31Wb5obOr-Jn32DFbvOYEg.png" /><figcaption>Kunduz</figcaption></figure><p>And using next-connect we could fetch a blog post in getServerSideProps function like so;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85553aaf9473ecf4aeec57fe18273544/href">https://medium.com/media/85553aaf9473ecf4aeec57fe18273544/href</a></iframe><p>We opted for the <strong>builder </strong>pattern, so that each builder shouldn’t deal with client bootstrapping etc..</p><h4>Perils of Wordpress Migration</h4><p>Next up was moving <strong>Wordpress </strong>to a <strong>subdomain</strong>, so that we could use our primary domain with <strong>NextJs</strong>. Given my history with <strong>Wordpress</strong>, I was very skeptical about this step of the process. There were documented cases of <strong>infinite redirect loops</strong>, <strong>SSL issues</strong>, <strong>login&amp;logout</strong> issues. 👻</p><p>The actual process was very straight forward. We just updated the <strong>“Wordpress Address”</strong> section under <strong>Settings -&gt; General</strong> and voila! Or so we thought.</p><p>After we saved the changes, our <strong>Wordpress </strong>installation froze. We couldn’t navigate the site, users couldn’t access the site because <strong>GraphQL </strong>endpoint wasn’t responding. And our database was under a very <strong>heavy load</strong>. Upon a closer inspection we determined the root cause was the <strong>Yoast SEO</strong> plugin. While searching for a solution, we came across a plugin called <strong>Yoast Helper</strong> that claims to fix these kinds of issues and I started to read the source code.</p><p>The fix was quite simple (finding the fix wasn’t), we just had to <strong>delete all records</strong> in certain Yoast tables in our database. Once we did that, the issue was resolved instantly. 🤌</p><h4>Other Improvements</h4><p><strong>Sitemaps:</strong> We wrote a function to get all urls of blog posts and pages from Wordpress and used these urls to create a .txt sitemap.</p><p><strong>Error Tracking:</strong> We added <strong>SentryJS </strong>to track all the errors. We are currently sitting at %99.9 crash free.</p><p><strong>Sessions:</strong> Just as a tease, we started retrieving user data and displaying a cheeky welcome message on our blog if the user is logged-in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*bMrbLH72K3z2qVB5PjBZKQ.jpeg" /><figcaption>Heyoo</figcaption></figure><h4>Overall</h4><p>We are quite happy with how things turned out. We can comfortably serve our users in <strong>2.5 seconds</strong>, we can integrate <strong>any </strong>tool in existence, we improved our <strong>analytics </strong>and <strong>data visibility</strong> a lot, our stack is <strong>current </strong>and <strong>up-to-date</strong>, we are using technologies that are <strong>easy </strong>to find new developers. There are still areas to improve but achieving a migration of this size in just 3 weeks and without any major issues or downtime is quite a feat itself. 💪</p><p>If you made it to this point, we hope you enjoyed reading. If you are also interested in <strong>web development</strong> and want to be a part of our team, you can <a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d"><strong>click this link</strong></a> and reach out to us.</p><p><a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d">Kunduz wants to meet you!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3eab760f0433" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kunduzinc/using-headless-wordpress-with-nextjs-3eab760f0433">Using Headless Wordpress with NextJs</a> was originally published in <a href="https://medium.com/kunduzinc">Kunduz, Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Publish Amazing Landing Pages?]]></title>
            <link>https://medium.com/kunduzinc/how-to-publish-amazing-landing-pages-a820918c8a49?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a820918c8a49</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[website-builders]]></category>
            <category><![CDATA[grapesjs]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 14:50:08 GMT</pubDate>
            <atom:updated>2021-09-07T14:50:08.737Z</atom:updated>
            <content:encoded><![CDATA[<p>It is no secret that <strong>landing pages</strong> are an important tool for growth. It is a great way to drive <strong>traffic</strong> and build <strong>SEO</strong>. Landing pages lead your potential users to your <strong>products</strong>, <strong>offers,</strong> or <strong>services</strong>. And for that reason, they are <strong>crucial</strong> in building a solid <strong>conversion</strong> mechanism.</p><p>And while landing pages are great for conversion, a <strong>poorly built</strong> landing page can <strong>hurt</strong> you. Your users may think your product or service is <strong>inferior</strong> once they are greeted with a poor landing page. A great landing page is a combination of <strong>good visuals</strong>, <strong>a clear message</strong> &amp; CTA, and <strong>high page loading performance</strong>.</p><p>So how can we create these high-quality pages? There are lots of tools and platforms for building and publishing landing pages out there. Some of them are <strong>free</strong> and some of them are not. Some offer <strong>hosting</strong>, some don’t. Some load really <strong>fast</strong> and others not so much. But most importantly, some of the best ones have a really good <strong>editor experience</strong>. This is often the most overlooked feature of these tools. If the editor experience is poor, it directly results in <strong>frustration</strong> and <strong>poorly built landing pages</strong>.</p><h3>Our Solution 💡</h3><p>We needed a tool to build landing pages for our website. But before diving into the tool itself, we want to provide a little bit of technical background. Here at <strong>Kunduz</strong>, we use <strong>WordPress</strong> for publishing our website. We have a custom-made WordPress <strong>theme</strong> using our company&#39;s <strong>UI kit</strong>, allowing<strong> </strong>for visual consistency across all web properties. And while we could have built each landing page from scratch individually, it is a great deal of workload on <strong>just a single developer </strong>when we consider that each page must be <strong>maintained</strong> and occasionally needs <strong>small changes</strong>. 🎨</p><p>This means our solution had to be easily used by editors and should fit in our existing toolchain. WordPress has lots of existing page builders and most of them come with their own themes and/or UI components. To achieve the sweet spot between <strong>editor experience</strong> and <strong>additional workload</strong>, we decided to develop our own page builder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hqwMtsL3j9QTC22WKZIGJg.png" /><figcaption>Kunduz’s very own Landing Page Builder (great name right? i know)</figcaption></figure><p>First, we needed a base to build on top of. Most of the heavyweight editor logic like <strong>dragging</strong>, <strong>dropping</strong>, <strong>converting UI elements to HTML,</strong> etc. is common and has already been solved by a product before us. While searching, we came across the amazing <strong>GrapesJS</strong>. It’s <strong>extensible</strong>, it’s <strong>robust</strong> and it’s <strong>open source</strong>. You can create your own little HTML <strong>blocks</strong> for your editor to drag into canvas and edit.</p><p><a href="https://grapesjs.com/">GrapesJS</a></p><p>After that, we needed to define what <strong>building blocks</strong> to offer our editors. After a couple of meetings and analyzing common patterns, we created a list of “components”. The list consists of common elements such as the <strong>Navbar</strong>, <strong>Hero</strong>, <strong>CTA</strong>, <strong>Feature List</strong>, and<strong> Footer</strong>. While we were hacking away on the editor itself, a very talented UI designer started to work on the components.</p><p>One by one, our block designs came to life when they were added to the GrapesJs editor. Everything was running smoothly with the editor but there was still the issue of saving the <strong>HTML</strong> contents to <strong>WordPress </strong>database 💾</p><p>Back then, we were using another great tool called <strong>react-admin</strong> as our back-office software. It is a turnkey solution to develop admin UI’s, based on ReactJS. Once we built our editor, we developed a small connector component in <strong>React</strong> so that the HTML output of the page builder was accessible by our <strong>CMS</strong>. To save content to WordPress, we leveraged their <strong>REST API</strong>.</p><p>This solution worked out great for a while. There were a few snags here and there, but overall the solution helped our editors build and publish landing pages efficiently and quickly — all without added effort from the single frontend developer.</p><p>And once it&#39;s time to sunset our back-office in favor of a greater tool, we needed to consider the <strong>Landing Page Builders’</strong> fate. Where was it supposed to go? And the answer was pretty obvious. Inside WordPress. 🤯</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4rRd2KnP09Ht9jWpzFN9IQ.jpeg" /><figcaption>A landing page builder with a sense of humor?</figcaption></figure><p>Overriding the default WordPress <strong>TinyMCE</strong> editor is no grand feat. Lots of builders have done it before, but surprisingly it’s a pretty poorly documented process. Most of the documentation is over a couple of years old and the fact that WordPress released a new editor experience called <strong>Gutenberg</strong> didn’t help. <strong>Gutenberg</strong> was the de-facto editing tool and none of the information out there provided a way to bypass it. That&#39;s why we used another plugin to revert to the classic editor first and then override it. 🤓</p><p>Overriding the editor is actually simple in practice. You call a couple of <strong>jQuery</strong> functions to hide <strong>TinyMCE</strong> editor and show yours. Then, you just need to listen to the <strong>save</strong> event and inject your editor’s HTML as page content. We packaged this solution as a WordPress plugin and installed it on our website.</p><p>We hope this solution will serve us years to come and help our editors build great pages. By switching, some of the <strong>withstanding bugs</strong> and “gotcha” moments solved themselves automatically. This re-enabled us to use <strong>Yoast SEO</strong> to analyze the landing page&#39;s content and edit elements like the title and description from the page. This was impossible before due to WordPress turning our HTML to gibberish on updating. 🈵</p><p>If you made it to this point, we hoped you learned important insights about developing landing pages. If you are also interested in <strong>web development </strong>and want to be a part of our team, you can <a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d"><strong>click this link</strong></a> reach out to us.</p><p><a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d">Kunduz wants to meet you!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a820918c8a49" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kunduzinc/how-to-publish-amazing-landing-pages-a820918c8a49">How to Publish Amazing Landing Pages?</a> was originally published in <a href="https://medium.com/kunduzinc">Kunduz, Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Page Speed With NextJs ]]></title>
            <link>https://medium.com/kunduzinc/optimizing-page-speed-with-nextjs-a26315201b01?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a26315201b01</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Mon, 31 May 2021 13:32:49 GMT</pubDate>
            <atom:updated>2021-06-21T10:03:50.467Z</atom:updated>
            <content:encoded><![CDATA[<p>If your web pages open quickly, you give a strong first impression. A fast-loading webpage leaves visitors happy and satisfied. With a basic psychological assumption, people find fast-loading web pages more professional and trustworthy. Humankind has always related speed with efficiency.</p><p>Nevertheless, this psychological assumption is not unrelated to real-world data. The faster your website gets, the more visitors will visit your pages. You won’t be losing people who don’t want to wait and give up. On average, you are losing 40% of your visitors if your web pages open longer than 3 seconds.</p><p>Aside from your visitors, Google, which is practically the monopoly of search engines, announced that they will use these performance metrics as indicators for search engine rankings. Because of this, it&#39;s almost vital to have a fast-loading website.</p><p><a href="https://developers.google.com/search/blog/2020/11/timing-for-page-experience">Timing for bringing page experience to Google Search</a></p><p>In Kunduz, we are presenting samples of our questions and answers online to convey the Kunduz experience better to our students. These pages are invaluable in our efforts to reach wider audiences and persuade students to signup.</p><p>We believe in the motto <strong>“Release early, release often”</strong> here in Kunduz. Because of this, we never wait for a project to mature fully before releasing. We improve and develop in iterations. And lately, we have been improving this project, which is online since January 2021. Now let&#39;s see what we have been doing and how it affected our metrics.</p><h3>Visuals 📸</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*TrcM74DVF80OtTvd386L2w.png" /><figcaption>A Question Page</figcaption></figure><p>As a <strong>Q&amp;A platform</strong>, the images on our platform come in many dimensions, sizes, and formats. And this diversity sometimes causes issues for a website visitor. If you add a 2000x3000 pixels image with a 1.5 mb size to your webpages, your visitor will have a poor experience.</p><p>To fix this, we developed a solution that resizes, rescales, reformats, and refilters images on the fly using <strong>AWS Lambda Edge Functions. </strong>With this solution, clients can request images in specific dimensions, formats, and with/without various filters. In our web pages, we used images at <strong>512px</strong> height and in <strong>WebP</strong> format. We also took into account that the width/height ratio shouldn’t be changed. This helped us reduce image sizes by <strong>90%</strong> percent. And by using images with a fixed height we improved our <strong>CLS (Cumulative Layout Shift)</strong> score.</p><p>We also added <strong>loading=lazy</strong> to every image in our web pages except for the question image. This is because if we had lazyloaded our question image, we would hurt our <strong>LCP (Largest Contentful Paint)</strong> score. For the question image to load even faster, we used a technique called <strong>preloading</strong> so that the image would start downloading as soon as possible.</p><p>Lastly, we blurred our answer images to better protect our IP and increase our conversion rates.</p><h3>Translations 🈯️</h3><p>In a startup with global ambitions like Kunduz, we always take localization into account when we are developing new features and products. We use a third-party service for managing translations in our projects. Translations are mostly created by Product Managers before each task and then used by client teams during development.</p><p>We create our web translations under a single package and every web property in Kunduz uses the same package. Whether a student trying to purchase a Q&amp;A package or a teacher trying to update their payment details use these translations from the same package.</p><p>Because of the nature of our toolset, NextJs, and next-i18next, these translations are added to the source of the pages as a javascript variable. This way, React can use these translations during the hydration phase. Including all of these translations, which grew over time, to each page request is a waste of resources. Students trying to see the answer to a question shouldn’t have to download a translation that is used to label a teacher&#39;s name input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*m4sTq42nAK_pP5QuxwzD3w.png" /><figcaption>The change in the HTML size</figcaption></figure><p>To fix this, we grouped our translations in the third-party providers&#39; control panel. And then we made developments to only include the required translation groups in our web pages. This helped us reduce our HTML size in <strong>half</strong>! A regular page that is used to be 130+kb is now 65+kb;</p><h3>Http/2</h3><p>Http/2 is a technology that is around for quite some time now. And somehow it slipped from our radar during the initial development phase. After a short config change in Nginx, we enabled it. This helped us increase our parallel request limit and shorten the time to load the website.</p><h3>Nginx Cache 🧠</h3><p>There will be times when you use every software development technique right and it just won’t be enough. While environmental factors like users&#39; device capabilities, network quality, etc. can cause this, the tools you choose as a developer might be the culprit too.</p><p>For this project, our tool of choice was <strong>NextJs</strong>. We chose <strong>NextJs</strong> because we already have a solid React investment in knowledge and in-house components and the fact that it can do <strong>SSR (Server Side Rendering).</strong> But making a request to Kunduz APIs in order to retrieve data in every page visit took a little more time than we anticipated.</p><p>In order to improve the load times, we decided to implement <strong>Content Caching</strong>. This way, the HTML output is stored for 24 hours and the subsequent requests are served via Nginx, before even hitting our <strong>NextJs</strong> app. This development reduced our <strong>TTFB (Time to First Byte)</strong> metric from 1 second to 100 milliseconds. 🤯</p><p><a href="https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/">NGINX Content Caching</a></p><h3>Web Vitals 📈</h3><p><strong>Web Vitals</strong> are a series of quality metrics for measuring web experience, initiated by Google. Its subset, <strong>Core Web Vitals</strong> are the most important ones.</p><ul><li><strong>LCP (Largest Contentful Paint);</strong> measures page loading performance.</li><li><strong>FID (First Input Delay);</strong> measures interactivity</li><li><strong>CLS (Cumulative Layout Shift);</strong> measures visual stability.</li></ul><p>We were tracking all these metrics from <strong>Google Search Console Tools</strong> and while it&#39;s a great tool, it didn’t provide us an instant feedback loop about our improvements.</p><p>So, we started to log every web vital to <strong>Google Analytics</strong>. It helped a great deal that <strong>NextJs</strong> was already measuring these metrics at every page load.</p><p><a href="https://nextjs.org/docs/advanced-features/measuring-performance">Advanced Features: Measuring performance | Next.js</a></p><p>Now we can track <strong>real Web Vitals data</strong> from <strong>real website visitors</strong> instantaneously.</p><h3>Other Developments 🗑</h3><p>Some optimizations don’t affect performance directly. So there were some developments mostly made to satisfy measuring tools.</p><ul><li>Adding <strong>alt</strong> tags to every image</li><li>Adding <strong>rel=noopener</strong> to every tag with an external URL</li><li>Converting every icon &amp; image to <strong>SVG &amp; WebP</strong></li><li><strong>Preloading</strong> every asset used from our <strong>CDN</strong></li></ul><p>We still have a lot to do in the accessibility area and we aim to address this soon.</p><h3>And Final</h3><p>With all these improvements, over the course of 1 May / 7 May;</p><ul><li>Lowered <strong>FCP</strong> from 3.51 to 2.05</li><li>Lowered <strong>LCP</strong> from 3.42 to 2.07</li><li>Lowered <strong>TTFB</strong> from 2.98 to 1.16</li></ul><p>While doing that, It was amazing to know that <strong>65%</strong> of our visitors were using mobile devices that have somewhat limited CPU and network capabilities.</p><p>We certainly don’t feel like we reached the final stage with this project. At <strong>Kunduz</strong>, we believe in continuous learning and development. When and if there is a better tool/method/solution, we will be using it to provide a better experience for our students.</p><p>Thank you If you make it to this point. If you are also interested in <strong>Web</strong> technologies and want to be a part of this team, you can <a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d"><strong>click this link</strong></a> reach out to us.</p><p><a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d">Kunduz wants to meet you!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a26315201b01" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kunduzinc/optimizing-page-speed-with-nextjs-a26315201b01">Optimizing Page Speed With NextJs 🚀</a> was originally published in <a href="https://medium.com/kunduzinc">Kunduz, Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NextJs ile Hız Optimizasyonu ]]></title>
            <link>https://medium.com/kunduzinc/nextjs-ile-h%C4%B1z-optimizasyonu-8923b38321be?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8923b38321be</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Mon, 31 May 2021 13:26:28 GMT</pubDate>
            <atom:updated>2021-06-01T12:51:51.714Z</atom:updated>
            <content:encoded><![CDATA[<p>Eğer web siteniz hızlı bir şekilde açılıyorsa güçlü bir ilk izlenim bırakırsınız. Hızlı açılan bir web sitesi ziyaretçileri mutlu ve memnun eder. Basit bir psikolojik çıkarımla, kullanıcılar hızlı açılan web sitelerini daha profesyonel ve güvenilir bulur. İnsanoğlu hız ve efektifliği hep ilişkilendirmiştir.</p><p>Ancak bu psikolojik çıkarım gerçek dünya sonuçlarıyla bağlantısız değildir. Aksine, ne kadar hızlı açılan bir siteniz varsa o kadar çok ziyaretçiniz olur. Sitenizin açılmasını beklerken sıkılan ve vazgeçen insanları kaybetmezsiniz. Ortalama olarak eğer 3 saniyeden yavaş açılan bir sayfanız varsa, ziyaretçilerinizin yüzde 40&#39;ını kaybettiğinizi düşünebiliriz.</p><p>Kullanıcılarınızın yanı sıra, arama motorları arasında adeta tekel durumda olan Google da Haziran 2021 itibari ile bu metrikleri arama sonuçlarını sıralarken kullanacağını duyurmuştur. Bu nedenle bir web sitesinin sayfa açılış süresi artık her zamankinden daha önemlidir.</p><p><a href="https://developers.google.com/search/blog/2020/11/timing-for-page-experience">Timing for bringing page experience to Google Search</a></p><p>Biz de Kunduz üzerinde paylaşılan soru ve cevap örneklerini, Kunduz deneyimini daha iyi aktarabilmek için web üzerinden açık bir şekilde sunuyoruz. Bu sayfalar yeni öğrencilere ulaşma ve öğrencilerin Kunduz’un kaliteli içeriklerini görerek üye olmalarına teşvik etmek için çok değerli bir araç.</p><p>Kunduz olarak “Release early, release often” felsefesine inanıyoruz. Bu sebeple bir projeyi yayına almak için hiçbir zaman 100% kusursuzluğa ulaşmasını beklemiyoruz. Geliştirme ve optimizasyonları iterasyonlar halinde parça parça yapıyoruz. Son günlerde de Ocak 2021&#39;den beri yayında bulunan bu projemizde çeşitli performans optimizasyonlarında bulunduk. Şimdi tek tek neler yaptığımızı ve nasıl fark yarattığımızı görelim.</p><h3>Görseller 📸</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*TrcM74DVF80OtTvd386L2w.png" /><figcaption>Bir soru sayfası</figcaption></figure><p>Bir soru cevap platformu olarak Kunduz’da yer alan soru / cevap görselleri çok çeşitli <strong>boyut</strong> (dimension), <strong>format</strong> ve <strong>büyüklüktedir </strong>(size). Ve bu çeşitlilik çoğu zaman web sitesi ziyaretçisi için en iyi sonucu vermez. 2000x3000 boyutunda, 1.5 mb büyüklüğünde görselleri sayfanıza eklerseniz ziyaretçileriniz sayfanızı görüntülemekte büyük gecikmeler yaşar.</p><p>Bu sorunu çözmek için <strong>AWS Lambda Edge</strong> fonksiyonlarını kullanarak görselleri istek anında boyutlandıran, formatlandıran ve cacheleyen bir altyapıyı hayata geçirdik. Bu altyapı sayesinde istemciler görselleri belirli boyutlarda ve formatlarda talep edebiliyorlar. Web sayfalarımızda da soru ve cevap görsellerini en boy oranı bozulmadan, <strong>512px</strong> yükseklikte ve <strong>WebP</strong> formatında kullandık. Bu sayede 90% üzerinde görsel büyüklüklerinde kazanımlar sağladık. Ayrıca görsel boyutları sabit kaldığı için <strong>CLS</strong> <strong>(Cumulative Layout Shift)</strong> değerlerimizi de iyileştirmiş olduk.</p><p>Bunun yanı sıra sayfanın en üstünde gösterilen soru görseli hariç tüm görselleri <strong>loading=lazy</strong> ile ile işaretledik. Soru görselini de <strong>preload</strong> ettik.i Bu sayede soru görselini tarayıcı daha henüz <strong>head</strong> tagini işlerken indirmeye başladık. Tüm bu optimizasyonlar bizim <strong>LCP (Largest Contentful Paint)</strong> değerimizi iyileştirdi.</p><p>Ayrıca, cevap görsellerini sunucu tarafında blurlayarak da hem conversion oranımızı arttırdık hem de kötü niyetli kullanıcılara karşı şirket bilgilerini koruma altına aldık.</p><h3>Çeviriler 🈯️</h3><p>Kunduz gibi global hedefleri olan bir şirkette yapılan projeler daima <strong>lokalizasyon</strong> faktörü hesaba katılarak geliştirilir. Projelerimizdeki dil dosyalarını yönetmek için üçüncü parti bir servis kullanırız. İlgili ekipler çevirileri girer ve yazılımcılar da bu çevirileri kullanarak uygulamaları geliştirir.</p><p>Çevirilerimizi tek bir web paketi altında yazarız ve Kunduz’un çeşitli web projeleri bu aynı paketi kullanır. Öğrenci panelinden soru paketi almaya çalışan öğrenci de, istatistiklerini görmeye çalışan eğitmen de bu aynı çeviri paketinden sağlanan değerleri kullanır.</p><p><strong>NextJS</strong> ve kullandığımız <strong>next-i18next</strong> paketinin yapısı gereği bu çeviriler sayfanın htmline bir javascript değişkeni olarak eklenir. Bu sayede React, hydration yaparken bu çevirileri kullanabilir. Zamanla büyüyen ve boyutu artan bu çeviri paketinin sayfaya her istekte eklenmesi oldukça gereksizdir. Bir soru detayı görmek isteyen öğrenci, eğitmenin panelinde kullanılan isim inputunun etiketini indirmemelidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*TmiE52jrXpGl7aLTaK_v0g.png" /><figcaption>Html boyutundaki değişim</figcaption></figure><p>Bu sorunu çözmek için tüm çevirilerimizi üçüncü parti çeviri servisinin panelinde gruplandırdık. Ardından da bu projede<strong> </strong>sadece ilgili grubun yüklenmesi ve kullanılması için geliştirme yaptık. Bu işlem bize <strong>50%</strong> oranında bir kazanım sağladı. Eskiden 130+ kb civarlarında oluşan sayfa htmli, 65 kb civarlarına geriledi.</p><h3>Http/2</h3><p>Http/2 yıllardır hayatımızda olan bir teknoloji olmasına karşılık bir sebepten dolayı projeyi ilk geliştirirken gözümüzden kaçmıştı. Kısa bir <strong>nginx</strong> değişikliği sayesinde bu özelliği de aktif hale getirdik. Bunun bize en büyük katkısı paralel yapılan bağlantı sayısını arttırarak içeriklerin daha kısa sürede indirilmesini sağlamak oldu.</p><h3>Nginx Cache 🧠</h3><p>Bazen tüm yazılım geliştirme tekniklerini doğru da uygulasanız yeterli performansa ulaşamayabilirsiniz. Kullanıcının internet hızı, kullandığı cihazın kapasitesi gibi çevresel faktörler buna etki edebildiği gibi, bir geliştirici olarak sizin kullandığınız teknolojilerin de bunda etkisi olabilir.</p><p>Kunduz’da bu projemiz için biz <strong>NextJs</strong> kullanıyoruz. Hem halihazırda olan React bilgimizi ve componentlerimizi kullanabileceğimiz, hem <strong>SSR</strong> <strong>(Server Side Rendering)</strong> yapabileceğimiz için bu teknolojiyi seçtik. Ancak her istekte <strong>NextJs</strong> tarafında Kunduz’un kendi API’lerine gidip ilgili sorunun datasının alınması, hem de html’in hazırlanıp ziyaretçiye gönderilmesi beklediğimizden daha uzun sürüyordu.</p><p>Bu nedenle sunucularımızda kullandığımız nginx konfigürsayonlarımıza <strong>Content Caching</strong> ekledik. Bu sayede bir istek kullanıcıya iletildikten sonra 24 saat saklanıyor ve bu süre içindeki isteklerde daha <strong>NextJs’e</strong> bile ulaşmadan sunucudan cevap doğrudan ziyaretçiye iletiliyor. Bu geliştirme <strong>TTFB</strong> değerimizi 1 saniyeden 100 ms civarlarına indirdi.🤯</p><p><a href="https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/">NGINX Content Caching</a></p><h3>Web Vitals 📈</h3><p><strong>Web vitals</strong>, Google tarafından öncülük edilen, kullanıcıların web üzerinde yaşadıkları tecrübenin kalitesini ölçmek için geliştirilen kalite metrikleri standartıdır. <strong>Core Web Vitals</strong> ise bu metriklerin en önemlilerine verilen isimdir. <strong>Core Web Vitals</strong>;</p><ul><li><strong>LCP (Largest Contentful Paint)</strong>; sayfanın yüklenme performansını ölçer.</li><li><strong>FID (First Input Delay)</strong>; sayfanın interaktivitesini ölçer.</li><li><strong>CLS (Cumulative Layout Shift)</strong>; sayfanın görsel stabilitesini ölçer.</li></ul><p>Kunduz olarak bu değerleri <strong>Google Search Console Tools</strong> üzerinden takip ediyorduk. Ancak bu şekilde hem anlık değerlere ulaşamıyorduk, hem de yaptığımız optimizasyonların geri bildirimlerine geç ulaşıyorduk.</p><p>Bu nedenle bu metrikleri her ziyaretçi için anlık olarak Google Analyticse logladık. Bunu yaparken NextJs’in zaten her istek için bu değeri hali hazırda ölçüyor olması işimizi çok kolaylaştırdı.</p><p><a href="https://nextjs.org/docs/advanced-features/measuring-performance">Advanced Features: Measuring performance | Next.js</a></p><p>Bu değerlerin okunduğu fonksiyonu Google Analytics’e bağlayarak artık anlık ve gerçek ziyaretçilerin değerlerini takip edebiliyoruz.</p><h3>Diğer geliştirmeler 🗑</h3><p>Bazı optimizasyonlar doğrudan performansı etkilemez. Biz de çoğunlukla ölçüm araçlarını memnun etmek için bazı geliştirmeler yaptık. Bunlar arasında;</p><ul><li>Tüm görsellere <strong>alt</strong> tagi eklemek</li><li><strong>target</strong> değeri <strong>_blank</strong> olarak ayarlanmış tüm linklere <strong>rel=noopener</strong> eklemek</li><li>Tüm ikon ve görselleri <strong>WebP &amp; Svg</strong> olarak kullanmak</li><li><strong>CDN</strong>’den kullanılan tüm assetlerimizi <strong>preload</strong> etmek</li></ul><p>geliştirmelerini sayabiliriz. Bu alanda özellikle şu an üzerinde çok mesai harcamadığımız erişilebilirlik ile ilgili daha çok işimizin olacağı aşikar.</p><h3>Ve final</h3><p>Bütün bu geliştirmeler sayesinde 1 Mayıs / 7 Mayıs sürecinde;</p><ul><li>3.51 sn olan <strong>FCP</strong> değeri -&gt; 2.05sn’ye</li><li>3.42 sn olan <strong>LCP</strong> değeri -&gt; 2.07sn’ye</li><li>2.98 sn olan <strong>TTFB</strong> değeri -&gt; 1.16 sn’ye</li></ul><p>düştü. Bu rakamlara ulaşırken; ziyaretçilerimizin <strong>65%’inin</strong> görece daha düşük internet ve cpu performansına sahip mobil cihazlar kullanıyor olması ise bizim için ekstra bir mutluluk oldu.</p><p>Geldiğimiz nokta asla bu projenin nihai ulaşacağı noktadır demiyoruz. <strong>Kunduz</strong> olarak daima ve sürekli olarak öğrenme ve gelişmeye inanıyoruz. Yarın daha iyi bir araç veya teknik ortaya çıkarsa daima bunu ziyaretçilerimize ve öğrencilerimize daha iyi bir tecrübe sağlamak için kullanıyor olacağız.</p><p>Buraya kadar okuduğun için teşekkür ederiz. Eğer sen de <strong>Web</strong> teknolojileriyle ilgileniyorsan ve bu ekibin bir parçası olmak istersen <a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d"><strong>hemen bu linkten</strong></a> bize ulaşabilirsin.</p><p><a href="https://www.notion.so/Kunduz-wants-to-meet-you-500873f72dca4bb59d88f55f6ac4527d">Kunduz wants to meet you!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8923b38321be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kunduzinc/nextjs-ile-h%C4%B1z-optimizasyonu-8923b38321be">NextJs ile Hız Optimizasyonu 🚀</a> was originally published in <a href="https://medium.com/kunduzinc">Kunduz, Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bir Bahar Temizliği Hikayesi]]></title>
            <link>https://medium.com/@emreyc/bir-bahar-temizli%C4%9Fi-hikayesi-d22033b61c4f?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d22033b61c4f</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Fri, 10 May 2019 17:15:55 GMT</pubDate>
            <atom:updated>2019-05-10T17:15:55.538Z</atom:updated>
            <content:encoded><![CDATA[<p>Tüm dependencyler outdated olmuştu 🎃 Bundle size gitgide büyüyordu 👻 Tam tüm umutları kaybetmişken o refactör geldi!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rn5T1c9_HIcb_yg8D2f9kA.png" /></figure><p>Frontend developerlar olarak NPM’i sevmeyenimiz ve kullanmayanımız yoktur diye düşünüyorum. Dependencyleri kurmamızı ve kullanmamızı bu kadar kolaylaştıran bu araç, peki maintenance için gerekli zamanı ayırmadığımızda koca bir kara deliğe dönüşebilir miydi? Peki hatta geliştirdiğimiz proje iyice monolith olmuşsa ve performansa olumsuz etki etmeye başlamışsa? Üzerine bir de bu projeyi yayına almak için ekstra kısıtlamalarınız varsa? 👻 Korku filmi gibi değil mi? Ya da çok tatlı bir pazartesi akşamı challange’ı 🚀</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FAFTWK5Qo22V2g%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fchandler-bing-AFTWK5Qo22V2g&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FAFTWK5Qo22V2g%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="288" frameborder="0" scrolling="no"><a href="https://medium.com/media/019f46bbf97974ef1f026deda49803c8/href">https://medium.com/media/019f46bbf97974ef1f026deda49803c8/href</a></iframe><h3>Durum</h3><p>Kunduz’da öğrencilerin paket satın alması için geliştirdiğimiz ve şirket içinde adına “Payment Flow” dediğimiz proje, Typescript ve React ile yazılan, Webpack ile build edilip bir makefile yardımıyla Wordpress üzerinde kurulu sitemizin temasının içine deploy edilen bir uygulama. Tek bir bundle oluşuyor ve içinde tüm kütüphaneler, stiller, ve business logic mevcut. Bu uygulamayı boş bir Wordpress sayfası içinde serve ediyoruz ve aslında sitenin bir parçası gibi gözüküyor. Sitenin css’lerinden bir kısmına depend ediyor.🛠</p><p>Bu projeyi 2018 Ekim ayında geliştirmeye başladık ve 2018 Kasım ayı sonunda yayına aldık. Şu ana kadar üzerinden 10.000&#39;den fazla transaction geçti ve Sentry.io datasına göre son bir ayda bug nedeniyle aldığımız hata sayısı 10&#39;dan az. (Kullanıcının cihazının network hatası alması nedeniyle bazen farklı hatalar gelebiliyor) 💪</p><p>Projeyi ilk yayına aldığımızda 420 kb olan bu bundle gziple 130kb’a düştüğü için zamanında çok dikkate almamıştık. Ancak daha sonradan eklenen ve geliştirilen feature’larla bu boyut 650 kb’ı aşınca artık müdahale etmenin zamanı geldiğini anladık.🎢</p><p>İlk günlerde deploymentları makefile dosyası ile kendi bilgisayarımdan yaparken artık Jenkins kullanmaya başladık ve bu projeyi sırf Wordpress içinde farklı bir klasör yapısı kullanması nedeniyle eklemeye üşenmiştim. Madem böyle bir refactor yapılacaktı, neden artık dosyaları yeni bir yere deploy edip burayı CDN mantığıyla kullanmıyorduk? 🌍</p><p>Bütün bu yapının üzerinde bir de 8 ayda güncellenen tüm NPM paketlerinin güncellenmesi gerekliliği eklenince artık sağlam bir refactor yapmanın zamanının geldiğini anladım ve “Payment Flow Spring Cleaning” isimli taskı JIRA’ya açtım. Ve olaylar şekillendi. 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUvbJ77N_Tsm_ZrtAPf6AA.png" /><figcaption>Kendin pişir, kendin ye, kendin task aç, kendin yap. Its the futbol thats the futbol.</figcaption></figure><h3>Dependency Güncellemeleri</h3><p>İlk iş “yarn outdated” komutu ile yeni versiyonu çıkmış paketlerin belirlenmesi oldu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6spT2_n_PHi1Yh5cqPvKSQ.png" /><figcaption>Update gerektirmeyeniniz var mı peki? Bu ne la?</figcaption></figure><p>Ardından, parça parça,</p><pre>yarn upgrade <em>paketadi</em> --latest</pre><p>komutu ile paketlerin en son versiyonlarına güncelleyip, güncellemeler arasında build alıp localde projeyi çalıştırarak kırılan yerleri kontrol edip fixlemeye başladım. Bu aşamada beni en çok zorlayan major bir update yayınlayan i18next (çoklu dil) plugini oldu. ㊗️</p><h3>Webpack Config Güncellemeleri</h3><p><a href="https://medium.com/frontend-t%C3%BCrkiye/javacript-polyfilleri-tarihe-mi-karisiyor-3f5fea57f430">Javascript Polyfilleri Tarihe mi Karışıyor?</a> başlıklı yazımı okuyanlar orda bahsettiğim Webpack optimizasyonlarını hatırlayacaktırlar. Bu projede de bahsedeceğim optimizasyonları yaptım.🎢</p><ul><li>Babel/preset-env için konfigürasyonu ve polyfilleri “usage” moduna aldım. Bu ne demek, artık polyfiller (gerçekten) .browserslistrc dosyamdaki konfigürasyona göre gelecekti.</li><li>Babel için <em>@babel/plugin-syntax-dynamic-import</em> pluginini kurdum. Bu plugin ilerde React component’lerimi lazy load etmeme yarayacak.</li><li>JS kodunun optimizasyonu için Terser pluginini kurdum. Bundle boyutuna çok etki etmese de kazanç kazançtır.</li><li>Chunkfile için içinde hash olan bir isim formatı verdim.</li><li>Publicpath için CDN adresi verdim. Bu sayede dynamic import olarak ayırdığım kodların doğru CDN adresinden gelmesini sağladım.</li></ul><h3>Projedeki Kodların Refactorü</h3><p>Buraya kadar yaptığım tüm değişiklikler iyiydi hoştu ama bundle boyutunun düşmesine çok etki etmemişti. Bunun için projeye gerçekten balta ile dalıp mantıksal parçalara bölmek gerekecekti.🔪</p><p>Kunduz’daki “Payment Flow” projemiz ilk başladığında tamamen öğrencilerin paket satın alması için düşünülmüş olmasına rağmen zamanla paketlerini, adreslerini ve ödeme araçlarını yönetebilecekleri bir dashboard ile desteklenmişti. Bu yüzden projeyi aslında mantıksal olarak authentication kısmı, ödeme kısmı ve dashboard kısmı olarak 3 parçaya rahatlıkla bölebilirdik.3️⃣✅</p><p>Parçaları belirledikten sonra 3 yeni React componenti yarattım ve içlerine yeni Routerlar tanımladım. Devasa app.js dosyasındaki routeları yeni yerlerine taşıyıp component importlarını da düzenledim. Artık projede 3 küçük react uygulaması ve 1 büyük ana uygulama vardı.</p><p>Ana uygulama içinde küçük uygulamaları React.lazy ile import edip, tüm projeyi React.Suspense componenti içine sardıktan sonra işim tamamlandı. 👍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DYPk9QrK_CaVStMdPZo29Q.png" /><figcaption>Çok lazy annecim.</figcaption></figure><h3>Aftermath</h3><p>Bu kadar değişikliği yaptık peki sonuç? Ana bundle size’ımız artık 398kb. Login için ek 48kb, ödeme için 44kb, panel için de ek 40kb’lık küçük paketler oluştu. Bu rakamların hepsi gzip olmadan, yani daha da azalacaklar. Ama en güzeli artık yeni gelen kullanıcı sadece login paketini indiriyor. Sadece paket satın almak isteyen kullanıcı, dashboard kodlarını indirmiyor.🛠</p><p>Dependency’lerimizin hepsi yeni, hepsi gıcır gıcır, hepsinde son 6 aydaki bütün yeni feature’lar ve güvenlik fixleri var. Jenkins entegrasyonu sayesinde CI/CD’ye kavuştuk. Artık öğrencilerin paket alma süreçlerine daha hızlı müdahale edip gelecekteki optimizasyonları daha güvenli bir şekilde yayına alarak hem onların yaşadığı experience’ı sürekli iyileştirebileceğiz hem de bu durumun converstion ratelere etkisi ile şirketin kısa ve uzun vadeli hedeflerine direk etki edebileceğiz.💰</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F8JW82ndaYfmNoYAekM%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fintuitquickbooks-danny-devito-quickbooks-intuit-8JW82ndaYfmNoYAekM&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2F8JW82ndaYfmNoYAekM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/c67dc0d75dd43c38bb72348f8087c48c/href">https://medium.com/media/c67dc0d75dd43c38bb72348f8087c48c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d22033b61c4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript Polyfillleri Tarihe mi Karışıyor?]]></title>
            <link>https://medium.com/@emreyc/javacript-polyfilleri-tarihe-mi-karisiyor-3f5fea57f430?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f5fea57f430</guid>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Fri, 05 Apr 2019 10:01:49 GMT</pubDate>
            <atom:updated>2019-04-05T10:01:49.561Z</atom:updated>
            <content:encoded><![CDATA[<h4>Eski &amp; yeni her tarayıcıda aynı bundle’ı yüklemek mantıksız değil mi?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_0X9nIcKiH81U9_ipY9aQ.jpeg" /><figcaption>Görseli biyerlerden apardım, güzel durdu ama, sarı enerjiktir.</figcaption></figure><p>Günümüzde hızla gelişen ve değişen Javascript bundan birkaç yıl öncesine kadar böyle değildi. 2015 yılında çıkan ES6&#39;dan sonra dil artık baş döndürücü bir hızla gelişiyor. Bu gelişmenin avantajları ve dezavantajları herkes için objektiftir ama <strong>class</strong> yapısı ya da <strong>spread</strong> operatörü gibi yeniliklere kimsenin itiraz edeceğini düşünmüyorum. Bu yenilikler, yazılımcının geliştirme verimini arttırdığı gibi ekosistemin gelişme hızına da katkıda bulunuyor. 🚀</p><p>Tabii ki bu geçiş süreci kolay olmadı. Ziyaretçilerinin çoğu eski tarayıcılar kullanan şirketler ve siteler uzun süre geçişi yapamazken bu süre içinde ES6 bir hobi olarak kaldı. Gulp, Grunt gibi build araçları gelmeden önce polyfiller için yeni bir script tagı açıp yeni bir asset eklendi. Bu araçlar geldikten sonra da bu polyfiller bunde’ların içine girip boyutu büyüttü. Webpack gelip de web’de dynamic import yeteneklerine kavuşana kadar da bu durum devam etti.</p><p>Günümüzde ise artık tarayıcıların çoğu ES6 özelliklerini destekliyor. Bu da polyfill kullanarak aslında ziyaretçilerimizin çoğuna, ihtiyacı olmayan assetleri yüklediğimizi bize gösteriyor❗️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lUcW6AgswONblvfBVVr8lA.png" /></figure><h3>Yöntem</h3><p>Bugünlerde bu problemi ortadan kaldırmak için yeni bir yöntem var. Eski tarayıcılara polyfill içeren, yeni tarayıcılar için ise içermeyen bundle’lar yaratmak bilinen bir teknik olmasına rağmen sunucu tarafından render edilen sayfalar haricinde kullanımı kısıtlıydı. Eğer bir PWA sahibiyseniz kullanıcının tarayıcısını denetleyip doğru bundle’ı yükletmek hem zaman alıcıydı hem de bu işi yapacak kod da polyfill gerektirebilirdi. 🤦‍♂️</p><p>Tam burada, browser geliştiricilerin göreceli olarak yeni eklediği bir özellik olan <strong>nomodule</strong> özelliği (attribute) bize cankurtaran olabilir. Bu özellik, ilgili script taginin içeriğinin module olmadığı ve destekleyen modern tarayıcılar tarafından yüklenmemesi gerektiğini belirtir. Bu özelliğin tam tersi olan <strong>type=”module”</strong> (attribute) özelliği ise eski tarayıcılar için bilinmeyen bir type olduğu için sadece yeni tarayıcılarda yüklenir.</p><p>Bir örnekle açıklayalım;</p><pre>&lt;script type=&quot;module&quot; src=&quot;app.js&quot;&gt;&lt;/script&gt;<br>&lt;script nomodule src=&quot;classic-app-bundle.js&quot;&gt;&lt;/script&gt;</pre><p>Bu kod bloğunda yeni tarayıcılar:</p><ul><li><strong>type=”module”</strong> olarak gördüğü <strong>app.js</strong> dosyasını yükleyecektir.</li><li><strong>nomodule</strong> olarak gördüğü <strong>classic-app-bundle.js</strong> dosyasını es geçecektir.</li></ul><p>Eski tarayıcılar ise:</p><ul><li><strong>type=”module”</strong> (attribute) özelliğini nasıl handle edeceğini bilmediği için <strong>app.js</strong> dosyasını es geçecektir.</li><li><strong>nomodule</strong> onlara birşey ifade etmediği için <strong>classic-app-bundle.js </strong>dosyasını default davranışında olduğu gibi yükleyecektir.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZDzSCKGed7nlS%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fwin-ZDzSCKGed7nlS&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FZDzSCKGed7nlS%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="250" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e192fa41019809888a7ef5a191bee1d/href">https://medium.com/media/4e192fa41019809888a7ef5a191bee1d/href</a></iframe><p>Burada module olarak yüklediğimiz <strong>app.js</strong>’nin aslında tek bir modül olduğu gözünüzden kaçmamıştır umarım. Peki bu assetleri nasıl oluşturacağız dediğinizi duyar gibi oluyorum. O zaman:</p><h3>Enter Webpack 🎉</h3><p>“<em>Elinde çekici olan adam, her problemi çivi zanneder</em>” misali, frontend ile ilgili çoğu yapısal işte, bir numaralı çözüm aracım Webpack’tir. Ama Webpack de çekiç değil adeta bir isviçre çakısı olduğu için genelde daima çözümü barındırır.</p><p>İki farklı browser tipine asset sunabilmek için iki farklı webpack konfigürasyonuna ihtiyacımız var. Başlangıçta, projenizin root klasöründe bulunan <strong>.babelrc</strong> dosyasını silmeniz gerekitor. Çünkü artık birden çok Babel konfigürasyonu belirtmemiz gerektiği için bunları webpack configlerinin içine dahil edeceğiz. Şimdi öncelikle eski tarayıcılara sunacağımız assetlerin config objesine bakalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6e1d3a006d7269b98344756633e0961/href">https://medium.com/media/f6e1d3a006d7269b98344756633e0961/href</a></iframe><p>Bu konfigürasyonun entry, output ve plugins kısımları sizin projenizin yapısına göre farklılık gösterebilir. Burada önemli olan kısım zaten rules.</p><p>19–20 ve 21. satırda gözüktüğü gibi <strong>esmodules</strong> değerini <strong>false</strong> yapıyoruz. Bu ne demek? Tarayıcıda javascript modülleri yüklemeyi desteklemeyen bütün eski tarayıcılar için gereken tüm polyfillerin yüklenmesini sağlar.</p><p>Olayın mantığı şu: eğer bir tarayıcı javascript modüllerinin yüklenmesini destekleyecek kadar yeniyse zaten <strong>async/await</strong>, <strong>promise</strong>, <strong>class</strong> ve <strong>arrow function</strong>ları destekliyordur.</p><p>Şimdi de modern tarayıcılar için sunacağımız gıcır gıcır assetleri yaratacak webpack config’ine bakalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11726172c89e746a4f980833f115575c/href">https://medium.com/media/11726172c89e746a4f980833f115575c/href</a></iframe><p>Bu yeni config’de öncelikle dikkatiniz output kısmına çekmek istiyorum. Gördüğünüz gibi dosyanın uzantısı <strong>.mjs</strong> olarak ayarlanmış. Bu uzantı, (module js’nin kısaltılması) browserların dosyayı doğru işlemesi için gerekiyor.</p><p>Gene 19–20 ve 21. satıra bakarsak, bu sefer <strong>esmodules</strong> değerini <strong>true</strong> olarak görüyoruz. Bu sayede kodumuz herhangi bir transpile işlemine girmeden, çok daha küçük bir boyutta çıkacak.</p><p>Eğer “html-webpack-plugin” gibi pluginler kullanarak oluşan assetlerinizi html dosyasına ekliyoranız, bu yeni yapıda .mjs dosyalarının da eklendiğini, ve doğru <strong>nomodule</strong> ve <strong>type=”module”</strong> attributeları ile eklendiğinden emin olmanız gerekiyor.</p><p>Peki bu iki ayrı konfigürasyonu webpack’e nasıl sunacağız? <strong>webpack.config.js</strong> dosyanızın export kısmında iki konfigürasyonu da bir array olarak kullanabilirsiniz.</p><pre>module.exports = [<br>  legacyConfig, moduleConfig<br>];</pre><h3>Performans Kazanımı</h3><p>Peki bu kadar değişikliğe gerçekten değer mi? Ne kadar bir performans artışı elde edeceğiz? Bunu test etmek için halihazırda canlıda olan projelerimden birine bu optimizasyonları uyguladım.</p><p>Eski browserlar için oluşan bundle <strong>594kb</strong> olarak oluştu. 🐢</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GFBLmt5YxT2YnygNU4p-eg.png" /></figure><p>Modern tarayıcılar için oluşan bundle ise <strong>527kb</strong> oldu. 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdLIf0HVUgQq9jr7RC-Znw.png" /></figure><p>Gzip öncesi kazanımımız <strong>%11</strong>. Bu rakam göze az gözükse de, 5 dakikalık çok kolay birkaç satırlık değişiklik ile elde edebiliyor olmak oldukça iyi. Bu optimizasyonları tree shaking ve dynamic importlar ve service workerlar ile birleştirdiğimizde ise performans kazanımları kullanıcı tarafında çok daha hissedilebilir olacaktır.</p><p>Sonuç olarak son görselimiz de “peki bu benim gerçekten işime yarayacak mı❓” diyenler için gelsin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFvzbYBw4oIPlkk5PDFZVA.png" /><figcaption>Destek baya iyi</figcaption></figure><p>Görseldeki kırmızıların çokluğu sizi yanıltmasın.</p><ul><li>Global olarak %84 desteklenmesi ✅</li><li>Desteklenmediği yerde fallback assetlerin hazır olması ✅</li><li>Implement etmesi sadece 5 dk sürmesi ✅</li></ul><p>gibi etkenleri göz önüne alınca, büyük küçük her projeye katkı sağlayabilecek bu yöntem, kesinlikle 2019 yılında javascript polyfilllerinin sonunu hazırlayacak gibi gözüküyor. (en azından es2019 polyfillerini kullanmaya başlayıncaya kadar) 🤦‍♂️</p><p>Kaynaklar</p><ul><li><a href="https://web.dev/fast/serve-modern-code-to-modern-browsers/codelab-serve-modern-code">Serve modern code to modern browsers for faster page loads | web.dev</a></li><li><a href="https://philipwalton.com/articles/deploying-es2015-code-in-production-today/">Deploying ES2015+ Code in Production Today</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f5fea57f430" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React ve Google Optimize ile Dinamik A/B Testleri]]></title>
            <link>https://medium.com/@emreyc/react-ve-google-optimize-ile-dinamik-a-b-testleri-8c14dcdb88f9?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c14dcdb88f9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ab-testing]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Wed, 23 Jan 2019 08:28:23 GMT</pubDate>
            <atom:updated>2019-01-23T08:28:23.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*5vlem2hirY1jr_jXt8-QZA.png" /><figcaption>Kaynak: Optimizely</figcaption></figure><p>A/B Testi, sözlük tanımı olarak, bir web sayfasının ya da web fonksiyonalitesinin iki versiyonunun birbiriyle yarıştırılıp hangisinin daha iyi sonuçlar ortaya çıkardığını görmemizi sağlayan testlerdir. Pratikte ise iki ya da daha fazla varyasyonun kullanıcılara random şekilde sunularak hangi varyasyonun belirlenen hedefe ulaşmaya daha yatkın olduğunun istatistiksel analiz metodlarıyla bulunmasıdır.</p><h3>Google Optimize</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcPL3vtAisyd6Us3pGhh0A.jpeg" /><figcaption>Optimize’ın dinamik varyasyon editörü ile CSS değişiklikleri çok kolay.</figcaption></figure><p>Google’ın ücretsiz olarak sunduğu bir hizmet olan Optimize, web sitenizde A/B testleri yapmaya yarar. Testlerinizi takvimleyebilir, birden fazla varyasyon ekleyebilir, her varyasyon için görsel bir editör yardımıyla CSS değişiklikleri yapabilir, ve hatta değişiklikleri gruplayıp Multi Variate Testing denen, grupları çapraz eşleştirip alt testler oluşturan teknolojiyi dahi kullanabilirsiniz. Google ürünlerinin birbiriyle uyumlu çalışması esasına dayanarak, Google Analytics hesabınızda tanımlı funnellar ve sayfaları testlerinizde hedef ve lokasyon olarak kullanabilirsiniz. Her testiniz için hem Optimize panelinde hem Analytics panelinde raporlarınız otomatik olarak oluşur. Ve bütün bunlar bedavadır.</p><blockquote><strong><em>Optimize ile statik sitelerde test yaratmanın ne kadar kolay olduğunu az çok anladık, peki ya client side teknolojiler ile geliştirilen dinamik web sayfaları?</em></strong></blockquote><h3>React ile Dinamik Testler</h3><p>React ile dinamik testler yapabilmek için <em>window</em> global objesi üzerinde optimize testini ve variant değerini okuyan bir component yazıp ilerlememiz gerekiyor.</p><p><a href="https://github.com/emreycolakoglu/react-optimize">emreycolakoglu/react-optimize</a></p><p>Yukarıdaki plugini kendinize başlangıç olarak alabilirsiniz. Bu plugin iki adet component içeriyor. <em>Experiment</em> ve <em>Variant</em>. Ayrıca projenizde Google Optimize container id’nizi eklemeniz gerekiyor. Mesela analytics.js kullanıyorsanız aşağıdaki kodu düzeltmeniz gerekebilir.</p><pre>&lt;script&gt;<br>(function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,&#39;script&#39;,&#39;https://www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);<br>ga(&#39;create&#39;, &#39;UA-.......-.&#39;, &#39;auto&#39;);<br>ga(&#39;require&#39;, &#39;displayfeatures&#39;);<br>ga(&#39;require&#39;, &#39;ecommerce&#39;);<br><strong>ga(&#39;require&#39;, &#39;GTM-.......&#39;);<br></strong>ga(&#39;send&#39;, &#39;pageview&#39;);<br>&lt;/script&gt;</pre><p>Bu noktadan sonra artık testimizi kodlamaya hazırız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*55uxJMV2oeKf6MkymfXvTg.png" /><figcaption>React ve Google Optimize ile test</figcaption></figure><p>Yukardaki koddaki testte, <em>Experiment</em> componenti içinde testimizdeki her varyasyon için bir <em>Variant</em> componenti yaratıyoruz. <em>Experiment</em> ve <em>Variant</em> componentlerimize test ve varyasyon id’lerini parametre olarak verdikten sonra artık deploya hazırız.</p><p>Plugin’in yaptığı iş aslında çok basit. <em>ComponentDidMount</em> event’inin içinde</p><pre>window.google_optimize.get(this.props.id);</pre><p>fonksiyonunu çalıştırarak gösterilecek varyasyonu kontrol ediyor. Eğer bir varyasyon bilgisini okuyabiliyorsa da o değere karşılık gelen <em>Variant</em> componentini çiziyor.</p><p>Bu yaklaşımda testlerin yazılımcı tarafından koda eklenmesi ve yayına alınması biraz endişe verici olsa da yeni başlayanlar için oldukça hızlı ve basit bir yöntem olarak görünüyor. Eğer sizlerin de daha önceden React ekosisteminde A/B testi tecrübeniz varsa yorumlarda bildiğiniz best practiceleri paylaşabilirsiniz.</p><p>Hepinize iyi geliştirmeler.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c14dcdb88f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Webpack ile Performans Odaklı Dönüşüm]]></title>
            <link>https://medium.com/@emreyc/webpack-ile-performans-odakl%C4%B1-d%C3%B6n%C3%BC%C5%9F%C3%BCm-c17e94bf3d97?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c17e94bf3d97</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Thu, 25 Oct 2018 19:12:15 GMT</pubDate>
            <atom:updated>2019-04-09T15:15:02.312Z</atom:updated>
            <content:encoded><![CDATA[<p><em>GDG Devfest Eskişehir 2018&#39;de yaptığım sunumun makalesi.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-EpFCHLURlyy8SqqV2zqA.png" /><figcaption>Devfest 2017&#39;deki sunumumdan bir kare</figcaption></figure><p>2017 yılında Devfest Eskişehir’de hayatımdaki ilk teknoloji konferansı sunumumu yaparken çok heyecanlıydım. Sunum (bence) baya başarılı geçince bu sene de katılmayı 4 gözle bekledim desem yalan olmaz. 2017&#39;de uzun uzun Webpack’ten ve bir web projesine katacaklarından bahsetmiştim. Frontend developerların yıllardan beri karşılaştığı sorunlara, eski teknolojilere değinmiş, eksiklerden bahsetmiş ve Webpack’in bu eksiklere sunduğu çözümlerden bahsetmiştim. Bu kadar Webpack demişken, yıl içinde bunu kendi işimde (Arabam.com) kullanmasam biraz iki yüzlü bir davranış olurdu. Bu yüzden, Yazılım Geliştirme Müdürümüz gelip benden, çok hızlı açılan bir siteyi gösterip, “Bundan istiyorum!” dediğinde, yazacağım reçete belliydi.</p><p>Arabam.com olarak birincil platformumuzun web sitesi olduğunu söyleyebiliriz. Bu sebeple site ne kadar performanslı olursa, ne kadar temiz kodlanmışsa, yeni özellikler geliştirmesi ne kadar kolaysa, şirketin ve ürünün başarısı o oranda yükseliyor. 2018 yılı da Arabam.com için yeniliklerin yılı oldu diyebiliriz. Rakiplerinden farklı özellikler sunarak öne çıkan Arabam.com’da aşağıdaki özellikleri yayına aldık:</p><p><strong>Arabam Ne Kadar Eder?</strong> <a href="https://www.arabam.com/arabam-ne-kadar-eder">Link</a></p><p><strong>Hangi Araç Bana Uygun?</strong> <a href="https://www.arabam.com/araba-bul/soru?adim=1">Link</a></p><p><strong>Bi’Görelim</strong> <a href="https://www.arabam.com/bi-gorelim">Link</a></p><p><em>Sunumda bunlardan bahsettiğim için tekrar bu özelliklerin tanıtımına girmiyorum. Dileyenler linklerden bilgi alabilirler.</em></p><p><strong>Yeni Bir UI</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*FrqVaHeVRp9IwVhHNUpBbQ.png" /><figcaption>Eski UI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*7HV9-i9-XvWSkj0QL_yKqw.png" /><figcaption>Yeni UI</figcaption></figure><p>Bütün bu yeniliklere rağmen, eskiyen teknoloji stack’imiz bizi kısıtlamaya başlamıştı. Çok daha basit ve hızlıca yapabileceğimiz işler için hackler ve pluginler aramaya başlamıştık. Bu yüzden değişim gerekiyordu. Eski stack’imizi basitçe şöyle özetleyebilirim.</p><ul><li>ASP.NET MVC 5 Razor</li><li>AngularJS 1.5.8</li><li>Typescript 2.7</li><li>Scss</li><li>Gulp</li></ul><p>AngularJS’nin çalışma tarzı gereği, kullanılan bütün pluginlerin dosyalarının siz daha app.module(“arabam”) demeden önce kullanıcının tarayıcısına gönderilmiş olması gerekiyor. Lazy load yapmak isterseniz de sadece Single Page Application mimarisindeki projelerde route-route bu işlemi yapabiliyorsunuz. Böyle olunca bizim, sadece anasayfayı ziyaret eden kullanıcıya ilan verme süreçlerinden satın alma sürecine kadarki bütün kodları yüklemek zorunda kalmamız, kullanıcının bekleme süresine de sabrına da iyi bir etki yapması beklenemezdi.</p><p>Bu tarz sorunları AngularJS’de yönetmenin imkanı var tabii ki. Projenin ilk zamanlarında işin başında olan geliştiricilerin bilmemesi / umursamaması ya da süre kısıtlaması gibi nedenlerle uygulanmayan bu tarz teknikler ileriki zamanlarda projenin boğulmasına ve ömrünün kısalmasına neden olmuştu.</p><p>Bizim yeni bir mimariye ihtiyacımız vardı, bütün kod yazma stilimizi değiştirecek, gerektiği anda gerektiği kadar esnek olacak, kullanıcının siteyi gezinme performasını ön planda tutacak ve en önemlisi uzun vadeli olacak bir yapıya geçmemiz gerekiyordu. Bu nedenle de aşağıdaki stack’e geçtik. Burada kullandığımız her tool’u tek tek açıklayıp ayrıca seçme &amp; kullanma nedenlerimizden de bahsedeceğim.</p><ul><li>Webpack</li><li>Typescript</li><li>VueJS</li><li>ES6 Modules</li><li>Scss</li><li>Browserslist</li><li>Workbox</li><li>Chai, Mocha, Cypress</li><li>Penthouse</li></ul><h3>TypeScript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*sXgwKRaFp1UX_5CCNZ5zGg.png" /></figure><p>Microsoft tarafından açık kaynaklı olarak geliştirilen Typescript, basitçe, javascript koduna tip bilgileri eklemenizi ve build anında hataları görmenizi sağlayan bir dil.</p><p>Örnek resimde, greeter fonksiyonunun aldığı parametreyi string olarak tanımlarsak, ve aşağılarda bu fonksiyona bir rakam arrayi paslamaya çalışırsak bu hatayı daha build anında hatta bazı IDE’ler ve pluginler yardımıyla kod yazma anında görebiliyoruz. Bu da geliştiriciye zaman kazandırıyor.</p><h3>VueJs</h3><p>Burada VueJS’i uzun uzun anlatmaya gerek yok. VueJS bir UI view kütüphanesi. Dinamik data-binding yetenekleri olan, hızlı, küçük ve öğrenmesi kolay bir kütüphane. Bizim seçme nedenlerimiz arasında, bu güzel özelliklerinin yanında, sunucu tarafından hazırlanan html’ler ile de çalışması var. Ziyaretçi kaynaklarının arasında en yüksek dilimi Google arama sonuçlarının olduğu bir şirketin en önemli teknik özelliği, arama motorlarının doğru ve basitçe indexleyebilmesi için sunucu tarafından html sunmasıdır.</p><p>VueJS, React aksine hem component mimarisi, hem de sunucudan gelen html ile çalışabildiği için bizim seçimimiz oldu.</p><h3>Hexagonal Design Pattern — ES6 Modules</h3><p>Burada biraz sebep sonuç ilişkisi var aslında. Yazılımcılar arasında çok hype bir terim vardır. “Seperation of Concerns”. Bu terimi kullandığınız anda bir anda yazılımcı yerine mühendis gözüyle bakılırsınız. Şakası bir yana, her yazılımcı kariyerlerinin bir evresinde spagetti kod dolu bir projeyle çalışmıştır. Heryerin heryerde olduğu, bir değişiklik yapmak için dosyalar arasında kaybolduğu, o değişikliği yaptığında da 3 farklı yeri daha değiştirdiği / kırdığı projelerden ağzı yanan yazılımcı, kendi işlerinde bunu tekrarlamamak için artık daha dikkatli olur. “Seperation of Concerns” burada devreye girer. Temel özeti “Herkes kendi işini yapsın”’dır. Arabam.com’da <em>modal</em> (sayfa içinde açılan html içeren popuplar) ekranlarıyla çok uğraştığımız için oradan örnek vereceğim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*WebTyqkExjs-vx0Lcge-Qg.png" /><figcaption>Çare Modal Service!</figcaption></figure><p>Modal pluginleri gelir geçer. Çok kritik olmadıkları için ve birçok tarayıcı ve cihaz kombinasyonunu, scroll davranışlarını, mobil tarayıcılardaki toolbar davranışlarını kotarmanız gerektiği için de yazılımcılar arasında çok sevilmez. Plugin kullanalım denir. Plugin kullanılır. Peki ya günün birinde plugin geliştiricisi geliştirmeyi durdurursa? Üzerine bir de Chrome’un yeni versiyonunda bir API kaldırılırsa ve modal’larınız production ortamında çalışmamaya başlarsa? Çok basit, plugini değiştirirsiniz değil mi? Peki ya plugini 46 farklı dosya 219 yerde çeşitli ayarlarla kullanmışsa? Hepsinin tek tek temizlenmesi, yeni pluginin kodlarının eklenmesi, ayarlarının eklenmesi, belki farklı bir ekip tarafından testinin yapılması. Bir anda kaç adam/saatlik iş oldu. Hexagonal Design Pattern burada devreye giriyor. Bu pattern’a göre, üçüncü parti bir plugini değiştirmek sadece birkaç satır değiştirmekten ibaret olmalı, pluginin kodlanışı sizin projenizden soyutlanmalı ve ilgilendirmemeli. Şöyle ki;</p><blockquote>Bu pluginin kodlanışını bir servis içine alıp, dışarıya sadece init, show, hide, warning, success gibi kısayol fonksiyonlar sunarsak, plugin değiştirileceği zaman sadece servis içindeki kodlar değiştirilir ve proje kaldığı yerden devam eder.</blockquote><p>Yazılımcı, bir yazılım şirketinde ofis kirasından sonra en büyük gider kalemidir. Kazandığımız adam/saati bir düşünün. Sonra size kod kalitesi gibi gözüken bir olayın aslında farklı seviyelerde nasıl kazançlar getirebileceğini bir hayal edin.</p><h3>BrowsersList</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*i3X9nRDW1auBbgdGfPB5Dw.png" /></figure><p><a href="https://github.com/browserslist/browserslist">BrowsersList</a> temelde bir meta formatıdır. Projenizin desteklediği tarayıcıları özel bir formatta projenin içinde bir configuration dosyasında tutmanızı sağlar.</p><p>Örnek görselde görüldüğü gibi, “Tarayıcıların son iki versiyonu”, “Kullanım payı yüzde 1&#39;den büyük olan tarayıcılar” ya da “Türkiye’de kullanılan tarayıcıların yüzde 80&#39;ini desteklemiş olalım” gibi ayarlar verilebilir.</p><p>Bu ayarlar tek başına işe yaramıyor. Ancak AutoPrefixer, Babel gibi BrowsersList destekli araçlar bu ayarları ortak kullanabilir. Bu sayede polyfillerinizi ve css prefixlerinizi, hatta Babel buildlerinizi tek yerden yönetebilirsiniz.</p><p>Biz bir adım daha ileri gittik, <a href="https://github.com/browserslist/browserslist-ga">browserslist-ga</a> plugini ile Arabam.com’un kendi Google Analytics datasını kullandık. Böylece körü körüne Türkiye’nin yüzde 80&#39;ini destekle demek yerine, kendi ziyaretçilerimizin yüzde 90&#39;ını destekle diyebildik.</p><h3>Workbox</h3><p><a href="https://developers.google.com/web/tools/workbox/">Workbox</a>, Google tarafından geliştirilen bir kütüphanedir. Service worker geliştirirken sık sık yapılan işler için iyi test edilmiş hazır fonksiyonlar sunar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TxfIrAhdPZCClyJjPE1eHA.png" /><figcaption>Workbox</figcaption></figure><h3>Chai + Mocha + Cypress</h3><p>Bir ekip halinde kod yazdığınızda mutlaka kodda hatalar olur. Farklı yazılımcıların farklı zamanlarda bir koda dokunması, yetersiz dökümantasyon, acele ederek gözden kaçırılan case’ler, olmayan analiz dökümanları gibi sayısız sebepten dolayı kodlarda gözle görünmeyen hatalar olabilir. Bazen de bu hatalar, koddaki çok alakasız bir yerin değişmesi sonucu sonradan ortaya çıkar. Bu gibi durumlardan en hafif şekilde etkilenmek için kodlara testler yazılır. Hexagonal Design Pattern kullandığımız için hazırladığımız servislere ve yardımcı kütüphanelerimize unit testler hazırladık. Bu sayede ileriki sprintlerde mevcut kodlar bozulduğunda, mevcut testler hata aldığında önceden farkedebildik.</p><p>Test ekibinin Cypress kullanarak ekipçe geliştirdiği End-to-End testleri sayesinde de ilan verme, ilan arama, register, login gibi critical pathlerde oluşan hatalardan anında haberdar olabildik ve hızlıca aksiyon alabildik.</p><h3>Penthouse</h3><p>Bir kullanıcı bir websitesini ilk ziyaret ettiğinde, sayfada ilk olarak kullandığı cihazın ekran boyutlarına sığan kısmı görür. Bu alana above-the-fold içerik denir. Kullanıcıya servis edilen CSS’in optimizasyonunda, bu above-the-fold içerik dışındakilere ilk etapta ihtiyacı olmadığı fikri üzerinden ilerlenir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*_7s5u9IC452I8SUcCm-wXg.png" /><figcaption>Above the fold içerik</figcaption></figure><p><a href="https://github.com/pocketjoso/penthouse">Penthouse</a> da critical css yaratmaya yarayan bir araç. Sayfanın adresi, ekran boyutu ve mevcut büyük css dosyasının adresi verildiğinde çıktı olarak sadece ekran boyutunun içinde kalan html elementlerinin stillerini yeni bir dosyaya yazar. Bu dosya içeriği html’in &lt;head&gt; tagi içinde inline olarak kullanılabilir. Sayfanın büyük cssi de footer kısmında sunulabilir. Bu sayede ilk açılış performansı artar.</p><h3>Öncesi — Sonrası</h3><p>Bu kadar yazdıktan sonra artık biraz rakam vermezsek olmaz. Geliştirme işlemine başlamadan önce eski mimaride sunulan tüm assetlerin boyutlarını almıştık.</p><ul><li>Tüm Assetler ( js + css + font + image) <strong>971 KB</strong></li><li>Tüm Javascript <strong>311 KB</strong></li><li>Tüm CSS <strong>59 KB</strong></li></ul><p>Bütün geliştirme bittikten sonra da aşağıdaki değerleri elde ettik.</p><ul><li>Tüm Assetler ( js + css + font + image) <strong>312 KB</strong></li><li>Tüm Javascript <strong>44 KB</strong></li><li>Tüm CSS <strong>19 KB</strong></li></ul><p>Bu performans artışı, Google Analytics’e aşağıdaki gibi yansıdı.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*liathni4ZTKPcMBSv8Jrfw.png" /><figcaption>Anasayfa açılış süresi performansı</figcaption></figure><p>Kırmızı ile çizilen çizgi değişikliklerin yayına alındığı tarihi gösteriyor. Geliştirmeden önce 7 saniye ortalamasında gezinen açılış süresi 4 saniyeye indi. Trafiğinin yüzde 90&#39;ını mobil cihazlardan alan bir site için oldukça başarılı bir optimizasyon. Dosya boyutu ile açılış süresinin azalması arasında doğru bir orantının olmamasının sebebi kullanılan marketing ve analytics scriptlerinin aynı şekilde kalması diyebiliriz. Bazen en iyi sistemi, en esnek mimariyi kursanız da zincir daima en zayıf halkası kadar güçlü oluyor.</p><h3>Final</h3><p>“Web sitesi şirketleri” diyebileceğimiz firmalarda web projesinin kalitesi, esnekliği, test edilebilirliği, ölçeklenebilirliği ve kullanılan teknolojilerin niteliği, şirketin geleceğini ve başarısını doğrudan etkiliyor. Bu amaçla gerçekleştirdiğimiz bu dönüşüm, Webpack’in ve modern frontend araçlarının bize sağladığı esnek dünya sayesinde mümkün oldu. Ayrıca bu yeni mimarinin bir öncekinden daha uzun ömürlü olacağından da şüphe yok. ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c17e94bf3d97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Service Worker’lar ile Network First yaklaşımı]]></title>
            <link>https://medium.com/@emreyc/service-workerlar-ile-network-first-yakla%C5%9F%C4%B1m%C4%B1-9a8d9b12c025?source=rss-c23c0c2eead3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a8d9b12c025</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Emre Yasin Çolakoğlu]]></dc:creator>
            <pubDate>Tue, 12 Jun 2018 07:46:28 GMT</pubDate>
            <atom:updated>2018-06-12T07:46:57.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*e-9bja0rhFRKBI4GKoRM5g.png" /></figure><p>Bir önceki yazımda <a href="https://medium.com/arabamlabs/service-workerlar-ile-cache-first-yakla%C5%9F%C4%B1m%C4%B1-219bcd39a083">Service Worker’lar ile Cache First yaklaşımı</a>ndan bahsetmiştim. Bu yazıda ise Network First yaklaşımından bahsedeceğim. Network first yaklaşımı, networkten bir asset için yanıt beklerken süre uzarsa, asseti cache’den döner. Bu yöntem sayfanın açılma süresini daima belirli bir limitte tutmak için idealdir.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9549c2e9b7925621297b3c4931e5b67/href">https://medium.com/media/b9549c2e9b7925621297b3c4931e5b67/href</a></iframe><p>3.satırda, install anında birkaç dosyayı precache metodu içinde cacheliyoruz. Siz uygulamanız için kritik olan dosyaları burada belirtebilirsiniz.</p><p>8. satırda, fetch eventinde, önce networkten, network 400ms’den uzun sürede cevap verirse de cache’den asseti dönecek fonksiyonu yazıyoruz.</p><p>15. satırda, precache metodu service worker’ın install anında çalışır ve seçili assetleri cache’e alır.</p><p>24. satırdaki fromNetwork fonksiyonu parametre olarak bir request ve timeout alır, eğer requesti belirtilen timeout’ta bitiremezse Promise’ini reddeder.</p><p>34. satırdaki fromCache fonksiyonu, parametre olarak bir request alır ve istenen asseti cache’den döner.</p><p>Bu yaklaşımda kilit nokta “fromNetwork” fonksiyonunun, belirtilen timeout’ta işini bitiremezse, döndüğü promise reject olur. Bu sayede, fetch eventindeki kodda, catch fonksiyonu içinde bu eventi yakalayıp istenen asseti cache’den dönebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*HUnu3nbBSq2lDoOSllBkiA.png" /></figure><p>Önceki yazımda belirttiğim gibi, her projenin gereksinimi birbirinden farklıdır, ve yukarda verilen fonsiyonlar birbiriyle çalışmak zorunda değildir, business gereksinimlerinize göre lego gibi birbiriyle çeşitli şekilde birleştirip farklı implementasyonlar yaratabilirsiniz.</p><p>Ayrıca o tarihten beri, service worker’lar daha yaygın hale geldi. Artık Opera Mini harici bütün büyük tarayıcıların son sürümünde destekleniyor.</p><p><a href="https://caniuse.com/#feat=serviceworkers">Can I use... Support tables for HTML5, CSS3, etc</a></p><p>İyi geliştirmeler :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a8d9b12c025" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>