{"id":3843,"date":"2016-04-20T02:22:23","date_gmt":"2016-04-20T02:22:23","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3843"},"modified":"2016-04-20T02:22:23","modified_gmt":"2016-04-20T02:22:23","slug":"react-performance-improvements","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/react-performance-improvements\/","title":{"rendered":"React: Performance improvements"},"content":{"rendered":"<p>You can shortcut rendering this way:<\/p>\n<pre>\nnpm install --save react-addons-shallow-compare\n<\/pre>\n<p>And add this:<\/p>\n<pre lang=\"javascript\">\n  shouldComponentUpdate(nextProps, nextState) {\n    return shallowCompare(this, nextProps, nextState);\n  }\n<\/pre>\n<p>To make React smaller, add this<sup><a href=\"#footnote_0_3843\" id=\"identifier_0_3843\" class=\"footnote-link footnote-identifier-link\" title=\"https:\/\/reactjsnews.com\/how-to-make-your-react-apps-10x-faster\">1<\/a><\/sup><\/p>\n<pre lang=\"javascript\">\n    new webpack.DefinePlugin({\n      \/\/ A common mistake is not stringifying the \"production\" string.\n      'process.env.NODE_ENV': JSON.stringify('production')\n    }),\n    new webpack.optimize.UglifyJsPlugin({\n      compress: {\n        warnings: false\n      }\n    })\n<\/pre>\n<p>Then, follow the guy&#8217;s advice in the above reference and add this to package.json:<\/p>\n<pre lang=\"javascript\">\n  \"babel\": {\n    \"env\": {\n      \"production\": {\n        \"plugins\": [\n          \"transform-react-constant-elements\",\n          \"transform-react-inline-elements\"\n        ]\n      }\n    }\n  },\n<\/pre>\n<p>Once you&#8217;ve done this, enable a CDN like Cloudflare in front.<\/p>\n<ol class=\"footnotes\"><li id=\"footnote_0_3843\" class=\"footnote\">https:\/\/reactjsnews.com\/how-to-make-your-react-apps-10x-faster<span class=\"footnote-back-link-wrapper\"> [<a href=\"#identifier_0_3843\" class=\"footnote-link footnote-back-link\">&#8617;<\/a>]<\/span><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>Handful of tips I collected and tested against React 15 for performance<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[302,387,388,389,421],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3843"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3843"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3843\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}