最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Render blocking react.js and pageSpeedpage rank - Stack Overflow

programmeradmin3浏览0评论

In React.js's tutorial it shows that its javascript files need to be within the <head> which doesn't allow the page to render until it has finished loading.

It seems from this quick test that any website that requires react.js does not bode well with google's pageSpeed as it throws this issue "Eliminate render-blocking JavaScript and CSS in above-the-fold content"

My questions are:

  1. does this actually effect page speed
  2. does this issue mean google page ranking will also be effected

In React.js's tutorial it shows that its javascript files need to be within the <head> which doesn't allow the page to render until it has finished loading.

It seems from this quick test that any website that requires react.js does not bode well with google's pageSpeed as it throws this issue "Eliminate render-blocking JavaScript and CSS in above-the-fold content"

My questions are:

  1. does this actually effect page speed
  2. does this issue mean google page ranking will also be effected
Share Improve this question edited Jul 14, 2015 at 18:13 Jammer asked Jul 14, 2015 at 17:54 JammerJammer 1,5631 gold badge20 silver badges37 bronze badges 1
  • 2 React doesn't need to be in <head>. You're much better off putting it just before </body>. The other option is to add the defer attribute to the <script> tag including React. React's isomorphic features are designed to make page loads faster, not slower – Bojangles Commented Jul 14, 2015 at 17:56
Add a ment  | 

2 Answers 2

Reset to default 9

To expand on @Bojangels ment: You're better off loading React in a script tag just before the </body> closing tag as follows:

<html>
    <head>
        <title>This is my app!</title>
    </head>
    <body>
        <!-- Your body content --> 
        <script src="https://fb.me/react-0.13.3.min.js"></script> 
    </body>
</html>

Putting the script at the end will allow the rest of the html and your css rules to render before the script tag is reached and react-0.13.3.min.js is loaded.

Also as mentioned, you could add a defer attribute to the script tag like so:

<script src="https://fb.me/react-0.13.3.min.js" defer="true"></script> 

By adding a defer attribute you would acplish the following (source: mdn):

This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the document has been parsed.

As far as your second question about whether page load speed effects google search ranking, Moz (an SEO firm) wrote a post about page speed and ranking and concluded:

Our data shows there is no correlation between "page load time" (either document plete or fully rendered) and ranking on Google's search results page.

There is an npm that will help you Extract & Inline Critical-path CSS in HTML pages using webpack. Critical Webpack Plugin: https://github./nrwl/webpack-plugin-critical

This helped me in React.js and to resolve Optimize CSS Delivery after the Google's pageSpeed insights.

发布评论

评论列表(0)

  1. 暂无评论