Using Electrode to Improve React Server Side Render Performance By Up To 70%

  • js application platform that powers walmart.com with several goals in mind, including ease of use, re-usability of components across applications and, most importantly, performance.We use server side rendering for almost all of our applications for two reasons:Improved performance for the customerBetter for SEOIn our tests, however, we found that React’s renderToString() takes quite a while to execute — and since renderToString() is synchronous, the server is blocked while it runs.
  • Every server side render executes renderToString() to build the HTML that the application server will be sending to the browser.To solve this problem, we created two Electrode modules: Above the Fold Render (ATF) and Server Side Render Profiling and Caching (SSR Caching).
  • The average renderToString()call with this configuration took 153.80 ms.Electrode default, though, Electrode comes with renderWithIds:false, which gives us a renderToString() time of 124.80 ms. Not bad — Electrode’s default configuration has already improved render time by 19%!
  • That drops our renderToString() time all the way to 36.56 ms — an astounding 71% improvement from the default Electrode configuration, and a 76% improvement from our original, unoptimized test.
  • That means a 70% improvement won’t mean 90 ms, but 180 ms saved.Special Thanks:To Arunesh Joshi, Dmitry Yesin, and the home page team who have implemented the Electrode modules and are using them on the home page in production.To Caoyang Shi, for helping to gather data and ensuring we’re getting the right numbers!More Information:Check out Joel Chen’s post on ReactJS SSR Profiling and Caching or Arpan Nanavati’s post on Building React.js at Enterprise Scale.Check out my post about the release of Electrode, the customer-facing platform that powers Walmart.com.The Electrode website: www.electrode.io

We built Electrode, the react/node.js application platform that powers walmart.com with several goals in mind, including ease of use, re-usability of components across applications and, most…
Continue reading “Using Electrode to Improve React Server Side Render Performance By Up To 70%”

Building Size-Aware React Components – LogRocket

Building Size-Aware #ReactJS Components:  by @b_edelstein #JavaScript

  • When using an HTML5 Canvas that has to be re-drawn whenever its size changesWhen building a layout where the user can adjust the sizes of different panesWhen using elements or 3rd party libraries that require a known size like react-virtualized, fixed-data-table, etc.When rendering elements with absolute positioning that need their position adjusted when the container size changes.When animating an element’s size with CSS with additional logic that depends on this animated sizeSome of these behaviors may be achievable with CSS, or by managing window size with the onResize event, but in the interest of building React components that are maximally reusable, it makes sense to encapsulate this logic into the component itself.
  • This method is called whenever the component’s size or position changes, and can be used to trigger side effects or put the dimensions into state.This solves most of the earlier examples but there’s one issue — a chicken and egg problem.
  • As such, we don’t always know the dimensions in the render function, so it’s not entirely possible for the component to have render logic based on its dimensions.react-sizemeTo solve this problem, we turn to a library called react-sizeme.
  • This library is similar to react-measure but uses a clever solution to solve the aforementioned problem.react-sizeme does an initial, invisible render of the component to measure its size.
  • Usually this feels quite fast, but in practice, I’ve noticed a slight delay in detecting changes which can lead to a component feeling slow.In general, react-measure has less of a performance impact, so it should be used if possible, but in cases where a component’s initial render depends on its size, then react-sizeme is a good option.Resources

When building React apps, it is sometimes advantageous for components to have awareness of their size and position on screen. This is useful both for rendering content initially, but also for…
Continue reading “Building Size-Aware React Components – LogRocket”

React.JS Top 10 Articles for the Past Month (v.July 2017)

React.JS Top 10 Articles for the Past Month (v.July 2017). @reactjs #JavaScript

  • React.JS Top 10 Articles for the Past Month (v.July 2017)For the past month, we’ve ranked nearly 1,300 React JS articles to pick the Top 10 stories that can help advance your career.
  • (0.8% chance to be picked in the list)Topics in this list: Fiber, VR, Forms, Airbnb, Higher Order Component, Virtual DOM, Animation, TensorFlow, ES2017Open source of the month is included at the end.Top 10 for JavaScript, Node, Angular are posted separately in the publicationMybridge AI ranks articles based on the quality of content measured by our machine and a variety of human factors including engagement and popularity.
  • This is a competitive list and you’ll find the experience and techniques shared by the React leaders particularly useful.Under the hood: ReactJS — Entire React code base explained by visual block schemes (Stack+Fiber versions) [2,348 stars on Github].

For the past month, we’ve ranked nearly 1,300 React JS articles to pick the Top 10 stories that can help advance your career. (0.8% chance to be picked in the list)
Continue reading “React.JS Top 10 Articles for the Past Month (v.July 2017)”

#Reactjs component that renders children elements when they enter the viewport

  • The option allows you to specify how far below, above, to the left, and to the right of the viewport you want to begin displaying your content.
  • The option allows you to specify how far below the viewport you want to begin displaying your content.
  • The option allows you to specify how far to left of the viewport you want to begin displaying your content.
  • The option allows you to specify how far to the right of the viewport you want to begin displaying your content.
  • By default the throttling function is actually a debounce function so that the checking function is only triggered after a user stops scrolling.

react-lazy-load – React component that renders children elements when they enter the viewport.
Continue reading “#Reactjs component that renders children elements when they enter the viewport”

React.JS Top 10 Articles for the Past Month (v.May 2017)

React.JS Top 10 Articles for the Past Month (v.May 2017).

#JavaScript @reactjs

  • React.JS Top 10 Articles for the Past Month (v.May 2017)Since April 2017, we’ve ranked nearly 1,200 React.JS articles to pick the Top 10 stories (0.83% chance to be included) that can help advance your career.Topics included in this React list are: Performance, Progressive Web App, Sketch, Serverless Stack, AWS, Webpack, Funtional Components, VR, Cross Platform, Animation.
  • Open source of the month is included at the bottom and JavaScript Top 10 is published separately in the publication.Mybridge AI ranks articles based on the quality of content measured by our machine and a variety of human factors including engagement and popularity.
  • This is a competitive list and you’ll find the experience and techniques shared by the experienced React developers particularly useful.Twitter Lite and High Performance React Progressive Web Apps at Scale.

Since April 2017, we’ve ranked nearly 1,200 React.JS articles to pick the Top 10 stories (0.83% chance to be included) that can help advance your career.
Continue reading “React.JS Top 10 Articles for the Past Month (v.May 2017)”

Use create-react-native-app to Set Up a Simple React Native App

  • React Native requires a lot of initial set up to get an app going.
  • After creating the project we will run the development server which will print a QR code on the terminal.
  • We will install the app called on our mobile phone and use it to scan the QR code.
  • This will load our app on our mobile phone in development mode.
  • When make adjustments to our project the changes will be reflected on our phone.

React Native requires a lot of initial set up to get an app going. In this lesson, we will use create-react-native-app to do this initial setup for us. We will install create-react-native-app globally and create a new project.
After creating the project we will run the development server which will print a QR code on the terminal. We will install the app called Expo Client on our mobile phone and use it to scan the QR code.
This will load our app on our mobile phone in development mode. When make adjustments to our project the changes will be reflected on our phone. If we use console.log the messages will be printed in our terminal.
Download the Expo Client from App Store (https://itunes.apple.com/app/apple-store/id982107779?pt=17102800&ct=www&mt=8) or Google Play (https://play.google.com/store/apps/details?id=host.exp.exponent&referrer=www)

Continue reading “Use create-react-native-app to Set Up a Simple React Native App”

React, JSX and ES6 as a template language – Korbit Engineering – Medium

React, JSX and ES6 as a template language @poksme  #Reactjs #JavaScript #ES6

  • React, JSX and ES6 as a template languageThe last few years have seen an important popularity increase of front-end rendering frameworks and what once was a cosmetic paint coating using handwritten HTML and CSS became an abstracted JavaScript process that renders HTML and CSS.
  • The benefits of client-side HTML rendering are plenty but one down side is the rise of complexity for web integrators.What used to be rendered on the server using a template language (here moustache)……became a very noisy JavaScript module…The majority of the content of this file is keywords and software development notions (module, object, function, point dereference…).
  • Using ES6 syntactic sugars and react functional component we can greatly reduce this noise.What happened here?
  • Technically speaking, we export as default an arrow function that destructures its only argument (props) and returns some JSX.
  • The result is a much more simple syntax closer to a template.But does this scale?The benefit of this notation is that we get a declarative block at the top of the file that lists the needed properties and a template block at the bottom that uses the properties.At Korbit we have been using this component style for hyphen.to.

The last few years have seen an important popularity increase of front-end rendering frameworks and what once was a cosmetic paint coating using handwritten HTML and CSS became an abstracted…
Continue reading “React, JSX and ES6 as a template language – Korbit Engineering – Medium”