{"id":1407,"date":"2020-08-14T16:40:56","date_gmt":"2020-08-14T16:40:56","guid":{"rendered":"https:\/\/lvboard.infostore.in.ua\/?p=1407"},"modified":"2020-08-14T16:40:56","modified_gmt":"2020-08-14T16:40:56","slug":"14-javascript-code-optimization-tips-for-front-end-developers","status":"publish","type":"post","link":"https:\/\/lvboard.infostore.in.ua\/?p=1407","title":{"rendered":"14 JavaScript Code Optimization Tips for Front-End Developers"},"content":{"rendered":"\n<p id=\"a71b\">JavaScript has become one of the most popular programming languages of all time. It is used by almost 96% of websites all over the world according to\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/w3techs.com\/technologies\/details\/cp-javascript\" target=\"_blank\">W3Tech<\/a>. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p id=\"a71b\">One key fact you should know about the web is that you have no control over the hardware specifications of the devices your user would access your website on. The end-user may access your website on a high-end or a low-end device with either great or poor internet connection. This means that you have to make sure your website is optimized as much as possible for you to be able to satisfy the requirements of any user.<\/p>\n\n\n\n<p id=\"9736\">Here are a few tips for you to have a better-optimized JavaScript code that would result in greater performance.<\/p>\n\n\n\n<p id=\"96c7\">As a side-note, make sure to share and reuse your JS components to keep the right balance between high-quality code (that takes time to produce) and reasonable delivery times. You can use popular tools like&nbsp;<a href=\"https:\/\/bit.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Bit<\/strong><\/a>&nbsp;(<a href=\"https:\/\/github.com\/teambit\/bit\" target=\"_blank\" rel=\"noreferrer noopener\">Github<\/a>), to share components (vanilla JS, TS, React, Vue, etc.) from any project to Bit\u2019s&nbsp;<a href=\"https:\/\/bit.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\">component hub<\/a>, without losing too much time over it.<a href=\"https:\/\/github.com\/teambit\/bit\" target=\"_blank\" rel=\"noreferrer noopener\">teambit\/bitDocumentation * Tutorials * Quick start guide * Workflows * bit.dev components cloud * Video demo Bit is an open-source\u2026github.com<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"217a\">1. Remove Unused Code and Features<\/h1>\n\n\n\n<p id=\"755c\">The more code your application contains, the more data needs to be transmitted to the client. It would also require more time for the browser to analyze and interpret the code.<\/p>\n\n\n\n<p id=\"80de\">Sometimes, you might include features that are not used at all. It is better to keep this extra code only in the development environment, and not to push it for production so that you would not burden the client\u2019s browser with unused code.<\/p>\n\n\n\n<p id=\"5295\"><em>Always ask yourself whether that function, feature, or piece of code is a necessity.<\/em><\/p>\n\n\n\n<p id=\"00a0\">You can remove unused code manually or by using tools such as&nbsp;<a href=\"https:\/\/github.com\/mishoo\/UglifyJS#compressor-options\" target=\"_blank\" rel=\"noreferrer noopener\">Uglify<\/a>&nbsp;or&nbsp;<a href=\"https:\/\/developers.google.com\/closure\/compiler\/docs\/api-tutorial3\" target=\"_blank\" rel=\"noreferrer noopener\">Google\u2019s Closure Compiler<\/a>. You can even use a technique called tree shaking which removes unused code from your application. Bundlers such as Webpack provide this technique. You can read more about tree shaking over&nbsp;<a href=\"https:\/\/medium.com\/@bluepnume\/javascript-tree-shaking-like-a-pro-7bf96e139eb7\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. If you want to remove unused npm packages, you can use the command&nbsp;<code>npm prune<\/code>&nbsp;. More info can be read from&nbsp;<a href=\"https:\/\/docs.npmjs.com\/cli-commands\/prune.html\" target=\"_blank\" rel=\"noreferrer noopener\">NPM docs.<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"80f6\">2. Cache Whenever Possible<\/h1>\n\n\n\n<p id=\"482a\">Caching increases the speed and performance of your website by reducing latency and network traffic and thus lessening the time needed to display a representation of a resource. This can be achieved with the help of the&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Cache\" target=\"_blank\" rel=\"noreferrer noopener\">Cache API<\/a>&nbsp;or&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Caching\" target=\"_blank\" rel=\"noreferrer noopener\">HTTP caching<\/a>. You might wonder what happens when your content changes. The above caching mechanisms are capable of handling and regenerating the cache when certain conditions are met such as the publishing of new content.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"1138\">3. Avoid Memory Leaks<\/h1>\n\n\n\n<p id=\"5a9c\">Being a high-level language, JS looks after several low-level management such as memory management. Garbage collection is a process common for most programming languages. Garbage Collection in layman terms is simply collecting and freeing back memory of which has been allocated to objects but which is not currently in use in any part of our program. In programming languages like C, the developer has to take care of memory allocation and deallocation using&nbsp;<code>malloc()<\/code>&nbsp;and&nbsp;<code>dealloc()<\/code>&nbsp;functions.<\/p>\n\n\n\n<p id=\"5dab\">Even though garbage collection is performed automatically in JavaScript, there can be certain instances where it will not be perfect. In JavaScript ES6, Map and Set were introduced with their \u201cweaker\u201d siblings. This \u201cweaker\u201d counterpart known as WeakMap and WeakSet hold \u201cweak\u201d references to objects. They enable unreferenced values to be garbage collected and thereby prevent memory leaks. You can read more about WeakMaps&nbsp;<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"https:\/\/blog.bitsrc.io\/understanding-weakmaps-in-javascript-6e323d9eec81\">here<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"422c\">4. Try to Break Out of Loops Early<\/h1>\n\n\n\n<p id=\"3863\">Looping for large cycles can definitely consume a lot of precious time. That is why you should always try to break out of a loop early. You can do this with the help of the&nbsp;<code>break<\/code>&nbsp;keyword and&nbsp;<code>continue<\/code>&nbsp;keyword. It is your responsibility to write the most efficient code.<\/p>\n\n\n\n<p id=\"5e7f\">In the below example, if you did not&nbsp;<code>break<\/code>&nbsp;from the loop, your code will run the loop 1000000000 times which is clearly in an overload.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">let arr = new Array(1000000000).fill('----');<br>arr[970] = 'found';<br>for (let i = 0; i &lt; arr.length; i++) {<br>  if (arr[i] === 'found') {<br>        console.log(\"Found\");<br>        break;<br>    }<br>}<\/pre>\n\n\n\n<p id=\"082b\">In the below example, if you did not&nbsp;<code>continue<\/code>&nbsp;when the loop does not match your condition, you will still be running the function 1000000000 times. We only process the array element if it is in even position. This reduces the loop execution by almost half.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">let arr = new Array(1000000000).fill('----');<br>arr[970] = 'found';<br>for (let i = 0; i &lt; arr.length; i++) {<br>  if(i%2!=0){<br>        continue;<br>    };<br>    process(arr[i]);<br>}<\/pre>\n\n\n\n<p id=\"fd6a\">You can read more about loops and performance over&nbsp;<a href=\"https:\/\/www.oreilly.com\/library\/view\/high-performance-javascript\/9781449382308\/ch04.html\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"1ade\">5. Minimize the Number of Times the Variables Get Computed<\/h1>\n\n\n\n<p id=\"0239\">To reduce the number of times a variable gets computed, you can use closures. In layman terms, closures in JavaScript gives you access to an outer functions scope from an inner function. The closures are created every time a function is created-<strong>not called<\/strong>. The inner functions will have access to the variables of the outer scope, even after the outer function has returned.<\/p>\n\n\n\n<p id=\"0850\">Let\u2019s see two examples to see this in action. These examples are inspired from Bret\u2019s blog.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function findCustomerCity(name) {<br>  const texasCustomers = ['John', 'Ludwig', 'Kate']; <br>  const californiaCustomers = ['Wade', 'Lucie','Kylie'];<br>  <br>  return texasCustomers.includes(name) ? 'Texas' : <br>    californiaCustomers.includes(name) ? 'California' : 'Unknown';<br>};<\/pre>\n\n\n\n<p id=\"0b08\">If we call the above functions several times, each time a new object is created. For every call, memory is unnecessarily re-allocated to the variables&nbsp;<code>texasCustometrs<\/code>&nbsp;and&nbsp;<code>californiaCustomers<\/code>&nbsp;.<\/p>\n\n\n\n<p id=\"c0b0\">By using a solution with closures, we can instantiate the variables only once. Let\u2019s look at the below example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function findCustomerCity() {<br>  const texasCustomers = ['John', 'Ludwig', 'Kate']; <br>  const californiaCustomers = ['Wade', 'Lucie','Kylie'];<br>  <br>  return name =&gt; texasCustomers.includes(name) ? 'Texas' : <br>    californiaCustomers.includes(name) ? 'California' : 'Unknown';<br>};let cityOfCustomer = findCustomerCity();cityOfCustomer('John');\/\/Texas<br>cityOfCustomer('Wade');\/\/California<br>cityOfCustomer('Max');\/\/Unknown<\/pre>\n\n\n\n<p id=\"7ebc\">In the above example, with the help of closures, the inner function which is being returned to the variable&nbsp;<code>cityOfCustomer<\/code>&nbsp;has access to the constants of the outer function&nbsp;<code>findCustomerCity()<\/code>&nbsp;. And whenever the inner function is being called with the name passed as a parameter, it does not need to instantiate the constants again. To learn more about closures, I suggest you go through this&nbsp;<a href=\"https:\/\/medium.com\/@prashantramnyc\/javascript-closures-simplified-d0d23fa06ba4\" target=\"_blank\" rel=\"noreferrer noopener\">blog post<\/a>&nbsp;by Prashant.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"257f\">6. Minimize DOM Access<\/h1>\n\n\n\n<p id=\"0c09\">Accessing the DOM is slow, compared to other JavaScript statements. If you make changes to the DOM that would trigger re-painting of the layout, this is where things can get quite slow.<\/p>\n\n\n\n<p id=\"e46b\">To reduce the number of times you access a DOM element, access it once, and use it as a local variable. When the need is complete, make sure to remove the value of the variable by setting it to&nbsp;<code>null<\/code>&nbsp;. This would prevent memory leakage as it would allow the garbage collection process to take place.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"4ddb\">7. Compress Your Files<\/h1>\n\n\n\n<p id=\"63b8\">By using compression methods such as Gzip, you can reduce the file size of your JavaScript files. These smaller files would result in an increase in your website performance as the browser would need to download smaller assets.<\/p>\n\n\n\n<p id=\"a241\">These compressions can reduce your file size by up to 80%. Read more about compression&nbsp;<a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/optimizing-content-efficiency\/optimize-encoding-and-transfer#text_compression_with_gzip\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/miro.medium.com\/max\/5472\/0*yUVIcTARWrjWiaPw\" alt=\"Image for post\"\/><figcaption>Photo by&nbsp;<a href=\"https:\/\/unsplash.com\/@jjying?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noreferrer noopener\">JJ Ying<\/a>&nbsp;on&nbsp;<a href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noreferrer noopener\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"18af\">8. Minify Your Final Code<\/h1>\n\n\n\n<p id=\"061f\">Some people believe that minification and compression are the same. But on the contrary, they are different. In compression special algorithms are used to change the output size of the file. In minification, the comments and extra spaces in JavaScript files, need to be removed. This process can be done with the help of many tools and packages that can be found online. Minification has become standard practice for page optimization and a major component of front end optimization.<\/p>\n\n\n\n<p id=\"dcf4\">Minification can reduce your file size by up to 60%. You can read more about minification&nbsp;<a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/optimizing-content-efficiency\/optimize-encoding-and-transfer#minification_preprocessing_context-specific_optimizations\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"3204\">9. Use Throttle and Debounce<\/h1>\n\n\n\n<p id=\"ef08\">By using these two techniques, we can strictly enforce the number of times your event needs to be handled by your code.<\/p>\n\n\n\n<p id=\"6d9e\">Throttling is where you specify a maximum number of times a function can be called overtime. For example, \u201cexecute the&nbsp;<code>onkeyup<\/code>&nbsp;event function at most once every 1000 milliseconds\u201d. This would mean that if you type 20 keys per second, the event will be fired only once every second. This would reduce the load on your code.<\/p>\n\n\n\n<p id=\"c632\">On the other hand, debouncing is where you specify a minimum duration of time for a function to be run again since the previous execution of the same function. In other words, \u201cexecute this function only if 600 milliseconds have passed without it being called\u201d. This would mean that your function would not be called until 600 milliseconds have passed since the last execution of the same function. To know more about throttling and debouncing, here is a&nbsp;<a href=\"https:\/\/css-tricks.com\/the-difference-between-throttling-and-debouncing\/\" target=\"_blank\" rel=\"noreferrer noopener\">quick read for you<\/a>.<\/p>\n\n\n\n<p id=\"6a4f\">You can either implement your own debounce and throttle functions or you can import them from libraries such as&nbsp;<a href=\"https:\/\/lodash.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Lodash<\/a>&nbsp;and&nbsp;<a href=\"http:\/\/underscorejs.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Underscore<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"0ea2\">10. Avoid Using the Delete Keyword<\/h1>\n\n\n\n<p id=\"0bce\">The&nbsp;<code>delete<\/code>&nbsp;keyword is used to remove a property from an object. There have been several complaints regarding the performance of this&nbsp;<code>delete<\/code>&nbsp;keyword. You can view them&nbsp;<a href=\"https:\/\/github.com\/googleapis\/google-api-nodejs-client\/issues\/375\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/stackoverflow.com\/questions\/43594092\/slow-delete-of-object-properties-in-js-in-v8\/44008788\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. It was expected to be fixed in future updates.<\/p>\n\n\n\n<p id=\"680c\">As an alternative, you can simply to set the unwanted property as&nbsp;<code>undefined<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">const object = {name:\"Jane Doe\", age:43};<br>object.age = undefined;<\/pre>\n\n\n\n<p id=\"e27b\">You can also use the Map object as it\u2019s&nbsp;<code>delete<\/code>&nbsp;method is known to be faster according to&nbsp;<a href=\"https:\/\/jsperf.com\/delete-vs-map-prototype-delete\" target=\"_blank\" rel=\"noreferrer noopener\">Bret<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"2a36\">11. Use Asynchronous Code to Prevent Thread Blocking<\/h1>\n\n\n\n<p id=\"2a1b\">You should know that JavaScript is synchronous by default and&nbsp;<strong>is also single-threaded<\/strong>. But there can be instances where your code requires a lot of time to compute. Being synchronous in nature would mean that, this piece of code would block other code statements from running until it is done executing. This would reduce your performance overall.<\/p>\n\n\n\n<p id=\"ebe6\">But we can avert this situation by implementing asynchronous code. Asynchronous code was earlier written in the form of callbacks, but a new style of handling asynchronous code was introduced with ES6. This new style was called promises. You can learn more about callbacks and promises in the&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/Asynchronous\/Introducing\" target=\"_blank\" rel=\"noreferrer noopener\">official docs of MDN<\/a>.<\/p>\n\n\n\n<p id=\"546c\"><strong>But wait\u2026<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>JavaScript is synchronous by default and&nbsp;<strong>is also single-threaded<\/strong>.<\/p><\/blockquote>\n\n\n\n<p id=\"3cbb\">How can you run on a single thread yet still manage to run asynchronous code? This is where a lot of people get confused. This is possible thanks to the JavaScript engine that runs under the browser hood. A JavaScript engine is a computer program or an interpreter which executes JavaScript code. A JavaScript engine can be written in a wide variety of languages. For example, the V8 engine which powers Chrome browsers was written in C++, while the SpiderMonkey engine which powers Firefox browsers was written in C and C++.<\/p>\n\n\n\n<p id=\"7bf5\">These JavaScript engines can handle tasks in the background. According to&nbsp;<a href=\"https:\/\/dev.to\/steelvoltage\/if-javascript-is-single-threaded-how-is-it-asynchronous-56gd\" target=\"_blank\" rel=\"noreferrer noopener\">Brian<\/a>, the callstack recognizes functions of the Web API and hands them off to be handled by the browser. Once those tasks are finished by the browser, they return and are pushed onto the stack as a callback.<\/p>\n\n\n\n<p id=\"925d\">You might sometimes wonder, how does things happen with Node.js as it has no help of the browser to run. In fact, the same V8 engine that powers Chrome also powers Node.js as well. Here is an awesome&nbsp;<a href=\"https:\/\/medium.com\/better-programming\/is-node-js-really-single-threaded-7ea59bcc8d64\" target=\"_blank\" rel=\"noreferrer noopener\">blog post<\/a>&nbsp;by Salil that explains this process on the Node ecosystem.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"a84b\">12. Use Code Splitting<\/h1>\n\n\n\n<p id=\"73da\">If you have experience with Google Light House, you would be familiar with a metric called \u201cfirst contentful paint\u201d. It is one of the six metrics tracked in the Performance section of the Lighthouse report.<\/p>\n\n\n\n<p id=\"0bbf\">First Contentful Paint(FCP)measures how long it takes the browser to render the first piece of DOM content after a user navigates to your page. Images, non-white&nbsp;<code>&lt;canvas&gt;<\/code>&nbsp;elements and SVGs on your page are considered DOM content; anything inside an iframe&nbsp;<em>isn&#8217;t<\/em>&nbsp;included.<\/p>\n\n\n\n<p id=\"b0c3\">One of the best ways to achieve a higher FCP score is to use code splitting. Code splitting is a technique where you send only the necessary modules to the user in the beginning. This would greatly impact the FCP score by reducing the size of the payload transmitted initially.<\/p>\n\n\n\n<p id=\"706e\">Popular module bundlers such as webpack provide you with code splitting functionality. You can also get the help of native ES modules, to get individual modules loaded. You can read more about native ES modules in detail over&nbsp;<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"https:\/\/blog.bitsrc.io\/understanding-es-modules-in-javascript-a28fec420f73\">here<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"2044\">13. Use async and defer<\/h1>\n\n\n\n<p id=\"1371\">In modern websites, scripts are more intensive than HTML, where their size is bigger and they consume more processing time. By default, the browser must wait until the script downloads, execute it, and then it processes the rest of the page.<\/p>\n\n\n\n<p id=\"c643\">This can lead to your bulky script blocking the loading of your webpage. In order to escape this, JavaScript provides us with two techniques known as async and defer. You have to simply add these attributes to the&nbsp;<code>&lt;script&gt;<\/code>&nbsp;tags.<\/p>\n\n\n\n<p id=\"1b2c\">Async is where you tell the browser to load your script without affecting the rendering. In other words, the page doesn\u2019t wait for async scripts, the contents are processed and displayed.<\/p>\n\n\n\n<p id=\"074e\">Defer is where you tell the browser to load the script after your rendering is complete. If you specify both,&nbsp;<code>async<\/code>&nbsp;takes precedence on modern browsers, while older browsers that support&nbsp;<code>defer<\/code>&nbsp;but not&nbsp;<code>async<\/code>&nbsp;will fallback to&nbsp;<code>defer<\/code><\/p>\n\n\n\n<p id=\"7510\">These two attributes can greatly help you reduce your page loading time. I highly advise you to read&nbsp;<a href=\"https:\/\/flaviocopes.com\/javascript-async-defer\/\" target=\"_blank\" rel=\"noreferrer noopener\">this blog post<\/a>&nbsp;by Flavio.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"42c4\">14. Use Web Workers to Run CPU Intensive Tasks in the Background<\/h1>\n\n\n\n<p id=\"a266\">Web Workers allow you to run scripts in background threads. If you have some highly intensive tasks, you can assign them to web workers which would run them without interfering with the user interface. After creation, the web worker can communicate with the JavaScript code by posting messages to an event handler specified by that code. This can happen vice versa as well.<\/p>\n\n\n\n<p id=\"6415\">To know more about web workers, I suggest you go through the&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Web_Workers_API\/Using_web_workers\" target=\"_blank\" rel=\"noreferrer noopener\">MDN Docs<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p id=\"0a58\">That\u2019s it for this post. Drop your queries in the comments.<\/p>\n\n\n\n<p id=\"99d6\">Happy Coding!!<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h1 id=\"34e5\">Share &amp; Manage Reusable JS Components with&nbsp;<a href=\"https:\/\/bit.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bit<\/a><\/h1>\n\n\n\n<p id=\"80c1\">Use&nbsp;<a href=\"https:\/\/bit.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Bit<\/strong><\/a>&nbsp;(<a href=\"https:\/\/github.com\/teambit\/bit\" target=\"_blank\" rel=\"noreferrer noopener\">Github<\/a>) to share, document, and manage reusable components from different projects. It\u2019s a great way to increase code reuse, speed up development, and build apps that scale.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/miro.medium.com\/max\/800\/0*qlLlbIFk4wN2LfSm.gif\" alt=\"Image for post\"\/><figcaption>Example: exploring shared React components on&nbsp;<a href=\"https:\/\/bit.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bit.dev<\/a><\/figcaption><\/figure>\n\n\n\n<p><a href=\"https:\/\/bit.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\">The shared component cloud<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript has become one of the most popular programming languages of all time. It is used by almost 96% of websites all over the world according to\u00a0W3Tech.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[30],"tags":[113],"_links":{"self":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/1407"}],"collection":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1407"}],"version-history":[{"count":1,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/1407\/revisions"}],"predecessor-version":[{"id":1408,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/1407\/revisions\/1408"}],"wp:attachment":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}