<?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[comparaonline - Medium]]></title>
        <description><![CDATA[IT Blog - Medium]]></description>
        <link>https://medium.com/comparaonline?source=rss----aec869ba5469---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>comparaonline - Medium</title>
            <link>https://medium.com/comparaonline?source=rss----aec869ba5469---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:33:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/comparaonline" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A way to improve SSR performance for React]]></title>
            <link>https://medium.com/comparaonline/a-way-to-improve-ssr-performance-for-react-ab03ec14571c?source=rss----aec869ba5469---4</link>
            <guid isPermaLink="false">https://medium.com/p/ab03ec14571c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ssrs]]></category>
            <category><![CDATA[perfomance]]></category>
            <dc:creator><![CDATA[Guillermo Puente Sandoval]]></dc:creator>
            <pubDate>Wed, 12 Dec 2018 18:24:52 GMT</pubDate>
            <atom:updated>2018-12-12T18:56:12.125Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UxI1Dxa5LVSWJNzLmEVDg.jpeg" /></figure><p>At ComparaOnline, one of our main goals was to improve the performance in our marketplace app to bring a better experience for our customers, and for us, as developers. That means, that we needed to make a lot of changes in our code, architecture, and how we handle some tasks to improve the whole performance of our application and move into an architecture that would allow us to develop more performant features.</p><p>This process took us through a long way of learning, where we changed things in our application, both in SSR (Server Side Rendering) and CSR (Client Side Rendering).</p><p>In this post, we are going to share a summary of how Dynamic Serving helped us to improve SSR Performance.</p><h4>Front-End decisions impact in your BFF (Backend For Frontend)</h4><p>If you are thinking to implement SSR with your React application, you need a BFF (Backend For Frontend). This Backend is responsible of handle the requests sent by your users and then, render a bunch of React components related to that request. Keeping this in mind, sounds logic that every little decision impact in the performance of our BFF: use a particular library, effort needed to perform a task, algorithms, etc. In this way we usually forget this, and tend to overload the server.</p><p>One of the big topics in this aspect is how to deliver and present the content to your users through different screen sizes. You have several options, each with pros and cons: Responsive Design, Mobile Version, Dynamic Serving, etc.</p><p>At ComparaOnline, we use Responsive Design at the beginning, but while our app grew, increased its size, components and features, Responsive Design turn really expensive in performance topic, for us and our customers.</p><p>When you use Responsive Design, you always deliver the same code, the same response applies for all users that request the same url, no matter what device they are currently using. Once the code is delivered to our users, the styles (CSS) do the job needed to adapt the layout to the screen size of the device. This means that we deliver code (components) that the user probably never see. For example, in our case, many layouts for our mobile users has hidden components that not work well in mobile version or, we deliver extra styles for correctly show that component, but, why our users need download extra code or extra styles that only work on desktop? why deliver different versions of a component to all our users if they only need one of them?</p><p>Also, render all the components for our users, no matter if they are mobile users or desktop users, is really expensive. Our server needs perform an unnecessary effort rendering components that the user never see and never need.</p><p>By using React Components and modularity we achieved an easy transition to a better approach for our environment: Dynamic Serving.</p><p>This technique allows us deliver different versions of our layout and content depending on the device (and in consequence: screen size) of the user. Also, this allows us deliver the different versions of responses under the same url (a mobile url is not needed: ‘m.comparaonline.com’), taking advantage of our current SEO and avoiding extra SEO efforts in new mobiles urls. With this approach, our servers only need to render the components that are really needed for the screen size of the user, saving resources for processing more requests and reuse components that work on all screen sizes.</p><p>To use this technique, you need to handle every request depending on the user-agent header sent by the web browser (user-agent is sent to help servers understand which device is currently making the request). With this header, you can know if the request was made by a mobile device, tablet or desktop and render the right version.</p><p>If you are currently using expressJS, you can take advantage of express-useragent middleware. This middleware reads user-agent header, makes some calculations and injects user-agent information in every request that can be really useful.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc9e7fe0d67f181fe4ab8d4e544f97d5/href">https://medium.com/media/fc9e7fe0d67f181fe4ab8d4e544f97d5/href</a></iframe><p>Now, we can pass this info to our components as a prop and render the right version, even, you can take advantage of another tools like ‘react-universal-component’ and just import dynamically the version that you need (with this you can avoid render and delivery unnecessary code). Here is the official docs: <a href="https://github.com/faceyspacey/react-universal-component">https://github.com/faceyspacey/react-universal-component</a></p><p>You can organize your project structure in a way that allows you handle specific components for desktop, mobile and components that apply both.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*Vp0IzRb03uuZvN2ZvdSnmA.png" /><figcaption>A simple way of structure your project.</figcaption></figure><p>In this example we have a ‘components’ folder that have our main component (App.jsx) and 3 more folders: common (for components that apply for both versions), mobile (that have the main component to mount mobile version and specific mobile components) and desktop (same as mobile but for desktop).</p><p>If we expand folders, we can see a more detailed view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*cHrwNG_05ZHan_lJ6Kczmg.png" /><figcaption>Full view mobile and desktop folders.</figcaption></figure><p>As you can see, desktop and mobile has their own components folder. This is because mobile and desktop have specific components while the common folder store the components that applies to all versions.</p><p>Now, if you pass the useragent info to your main component (App.jsx) you can easily load the right version:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0bbbe7944acb6d58592df2338a0025c/href">https://medium.com/media/b0bbbe7944acb6d58592df2338a0025c/href</a></iframe><p>You can use Chrome devtools to emulate mobile devices and see how the code above deliver different layouts depending the user device:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIinm3QA--CyCL1g0x1kzA.gif" /><figcaption>Server deliver different code and versions of your layout depending user device.</figcaption></figure><p>As shown in the picture before, when we load the url from a mobile device, we receive a Header, Footer and content for mobile (see title inside each box), but when we load from desktop we receive a different layout version, now for desktop devices. Also, you can see that ‘common button’ applies for both requests, no matter the device.</p><p>Note that you are delivering only the ‘mobile-index.js’ (code just for mobile) when you request the url from a mobile, same story when you request the url from desktop (you will receive desktop-index.js). This way you are not only rendering the components needed for each version, also, you are sending just the code needed for your users.</p><p>Finally, if you are going to use Dynamic Serving, keep in mind that you need to specify a “Vary: User-Agent” header in the response. This is needed by google to correctly index your page: <a href="https://developers.google.com/search/mobile-sites/mobile-seo/dynamic-serving?hl=en">https://developers.google.com/search/mobile-sites/mobile-seo/dynamic-serving?hl=en</a></p><p>You can find the full code here: <a href="https://github.com/gpuente/dynamic-serving-demo">https://github.com/gpuente/dynamic-serving-demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab03ec14571c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/comparaonline/a-way-to-improve-ssr-performance-for-react-ab03ec14571c">A way to improve SSR performance for React</a> was originally published in <a href="https://medium.com/comparaonline">comparaonline</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creando una Aplicación con React Desde Cero]]></title>
            <link>https://medium.com/comparaonline/creando-una-aplicaci%C3%B3n-con-react-desde-cero-76f423e63d02?source=rss----aec869ba5469---4</link>
            <guid isPermaLink="false">https://medium.com/p/76f423e63d02</guid>
            <dc:creator><![CDATA[Ignacio Zabalza]]></dc:creator>
            <pubDate>Fri, 01 Sep 2017 16:36:07 GMT</pubDate>
            <atom:updated>2017-09-01T16:36:06.633Z</atom:updated>
            <content:encoded><![CDATA[<h4>Parte I — Levantando un Servidor de Desarrollo con webpack-dev-server</h4><p><em>Esta es la primera entrega de una serie de artículos en los cuales crearemos una aplicación con la misma arquitectura de Front-end que usamos en ComparaOnline. Para entender los conceptos expuestos aquí, asumo que alguna vez has programado en JavaScript y que has leído por lo menos lo básico de la documentación de React y Redux. Todo lo que sea necesario saber sobre otras librerías lo iré explicado en la marcha.</em></p><p>A cuatro años de su creación no es difícil encontrar varios recursos para aprender sobre react. La documentación oficial es bastante completa como para aprender incluso sobre conceptos avanzados. Sin embargo, incluso en este escenario, hay pocos recursos que muestren cómo combinar react con más de una librería (i.e. redux, react-redux, immutable, reselect, webpack, etc.).</p><p>Aprender sobre cada una de estas herramientas por separado es fácil: todas son relativamente simples y se enfocan en solucionar un problema en particular. Pero usar varias de ellas al mismo tiempo puede llevar a dificultades que salen a luz justamente al momento de combinarlas.</p><p>En los siguientes artículos voy a mostrar la arquitectura de una aplicación cuya funcionalidad es extremadamente simple. El objetivo es ver cómo las librerías se relacionan entre sí y cómo cada una de ellas resuelve el problema para el cual fue diseñada.</p><p>Mi intención no es profundizar en detalles que tengan que ver con un dominio en particular de la aplicación, sino más bien concentrarme en su estructura general. La idea es presentar una forma de combinar react, redux, reselect, entre otras. en una arquitectura coherente, dando especial énfasis a la implementación de aspectos transversales (modularización, traducciones, mantenibilidad, etc.).</p><p>Lo primero que haremos será crear un ambiente de desarrollo para nuestro proyecto.</p><h4><strong>Instalando </strong><strong>webpack-dev-server</strong></h4><p>Iniciaremos el proyecto escribiendo un script que npm pueda usar para echar a andar un servidor de desarrollo. Crearemos un nuevo directorio y dentro de este vamos a ejecutar los siguientes comandos:</p><pre>$ npm init -y<br>$ npm install --save-dev webpack webpack-dev-server</pre><p>webpack-dev-server nos permite hacer <em>hot-reloading</em>, lo que significa que cualquier cambio que hagamos al código automáticamente se verá reflejado en nuestro navegador. Para indicar a npm que use webpack-dev-server debemos añadir un script de start en la sección de scripts de package.json:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/988863d6969e12254b4b69c8e1b68624/href">https://medium.com/media/988863d6969e12254b4b69c8e1b68624/href</a></iframe><p>Si ahora ejecutamos:</p><pre>$ npm start</pre><p>Veremos un mensaje de error diciendo que para poder levantar webpack-dev-server necesitamos un archivo de configuración de webpack. Sin entrar en grandes detalles sobre lo que es webpack (ya que eso requiere un artículo aparte) solo voy a decir que obviamente está relacionado con webpack-dev-server y que una de sus funciones es crear <em>bundles</em>, o en otras palabras, archivos estáticos generados a partir de nuestro código (nuestros archivos con extensiones .js, .css, .coffee, etc)<em> </em>. En futuras entregas de esta serie entraremos en más detalle sobre lo que es webpack. Lo importante por ahora es enfocarnos en nuestro objetivo a corto plazo: levantar el servidor de desarrollo. Así que sin más preámbulo procedemos a crear el archivo de configuración:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f75d9200ff0049818d41427c1f1fb4d2/href">https://medium.com/media/f75d9200ff0049818d41427c1f1fb4d2/href</a></iframe><p>Esto es lo mínimo que podemos agregar a un archivo de configuración de webpack para que sea funcional. El campo entry tiene la ruta al archivo que servirá de punto de partida para el código JavaScript (vale la pena mencionar que entry puede estar compuesto por más de un archivo, pero para nuestros propósitos, solo necesitamos uno). El campo output está compuesto por: filename que contiene el nombre del <em>bundle</em> que webpack hará del entry, path que es el nombre del directorio donde se almacenará el <em>bundle</em>, y publicPath que corresponde a la ruta que usaremos para acceder al <em>bundle</em> desde una url. Todo esto quedará más claro una vez que hayamos creado los archivos que faltan para poder iniciar el servidor. Partiremos por main.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d75ea2790e286c3c54415debed825239/href">https://medium.com/media/d75ea2790e286c3c54415debed825239/href</a></iframe><p>Esta implementación trivial nos ayudará a verificar que nuestra configuración es correcta una vez que el servidor esté andando. A continuación crearemos el archivo index.html dentro del directorio dist. Este directorio será el que webpack-dev-server usará para servir los archivos estáticos. Dentro de index.html llamaremos a bundle.js, archivo que será el resultado del <em>bundle</em> delentry:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd6060f9031f2371ef5e94898a5bad88/href">https://medium.com/media/dd6060f9031f2371ef5e94898a5bad88/href</a></iframe><p>En nuestro caso en particular, podemos acceder a bundle.js directamente desde index.html debido a que el campo publicPath del archivo de configuración tiene el valor &quot;/&quot;, pero, por ejemplo, si cambiáramos ese valor a &quot;/assets&quot;, tendríamos que modificar también el valor de src (en la línea 9) de &quot;bundle.js&quot; a &quot;/assets/bundle.js&quot;. Con esto ya tenemos todo lo que necesitamos para configurar webpack-dev-server en package.json:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65a11a5af61adc3f092b50f14572d093/href">https://medium.com/media/65a11a5af61adc3f092b50f14572d093/href</a></iframe><p>Ahora podemos iniciar el servidor dirigiéndonos a la raíz del proyecto y ejecutando lo siguiente:</p><pre>$ npm start</pre><p>Si no cometimos ningún error de sintaxis, deberíamos poder acceder a index.html desde <a href="http://localhost:8081/">http://localhost:8081</a> en nuestro navegador. Lamentablemente, si hacemos esto, lo único que veremos es la estructura de directorios del proyecto debido a que aún no hemos indicado a webpack-dev-server desde que directorio tiene que servir los archivos estáticos. Para corregir esto, agregaremos la opción --content-base dist/ al script de start en package.json:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40aa75427ddae23b24d3464e600c8720/href">https://medium.com/media/40aa75427ddae23b24d3464e600c8720/href</a></iframe><p>Finalmente, si volvemos a ejecutar $ npm start, deberíamos poder ver la página index.html en blanco y el mensaje que definimos en main.js en la consola del navegador. Ahora, para verificar que el servidor efectivamente está haciendo <em>hot-reloading</em>, podemos modificar el mensaje de main.js y ver cómo se muestra en la consola sin necesidad de recargar el navegador.</p><p>Con los archivos que hemos agregado hasta el momento, la estructura de directorios del proyecto tiene la siguiente forma:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*BYh5_pOKdF1C_0gU0G0eFQ.png" /><figcaption>Estructura de directorios del proyecto</figcaption></figure><p>Antes que pienses que todo esto es un poco complejo para levantar un servidor de desarrollo, hay que considerar que esta es la configuración más básica de webpack-dev-server y que, por ende, aún no hemos usados varias de sus funciones más interesantes.</p><p>Una de sus características más atractivas es su gran disponibilidad de plugins que solucionan cosas como: integración con herramientas de terceros (por ejemplo UglifyJS), eliminación de código duplicado, etc.</p><p>Todas este conjunto de funcionalidades que quedan a nuestra disposición sin duda que justifican un <em>setup </em>más complejo a cambio de una mayor productividad a largo plazo.</p><p>En la próxima entrega vamos a crear nuestros primeros componentes en react basándonos en esta estructura inicial del proyecto. Adicionalmente, iremos introduciendo plugins de webpack-dev-server a medida que los vayamos necesitando.</p><p>¿<em>Quieres trabajar con nosotros? En ComparaOnline estamos buscando devs que quieran unirse al más transparente marketplace de productos financieros en LATAM. Somos un equipo joven que constantemente está investigando y aprendiendo sobre nuevas tecnologías. Contamos con múltiples beneficios como horarios flexibles, la posibilidad de realizar home office, entre muchas cosas más. ¿Interesado? ¡No dudes en escribirnos!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76f423e63d02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/comparaonline/creando-una-aplicaci%C3%B3n-con-react-desde-cero-76f423e63d02">Creando una Aplicación con React Desde Cero</a> was originally published in <a href="https://medium.com/comparaonline">comparaonline</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>