简体   繁体   English

创建反应应用程序页面速度混乱

[英]Create-react-app pagespeed confusion

I've been facing pagespeed problems using this tool from google 我一直在使用来自Google的工具遇到Pagespeed问题

My goal is to reach ~95 on pagespeed insights; 我的目标是达到约95的Pagespeed见解;

I use create-react-app, and after I've: 我使用create-react-app,之后:

  • Enabled gzip in nginx for all project files, 在Nginx中为所有项目文件启用了gzip,
  • Compressed all images as suggested by Google, 按照Google的建议压缩所有图像,
  • Used loadCSS polyfill to avoid css-blocking while page renders (I placed links of sanitize.min.css, and slick-carousel I use in public/index.html as suggested), 使用loadCSS polyfill避免在页面渲染时出现CSS阻塞(我建议在public / index.html中放置sanitize.min.css和slick-carousel链接),
  • Loaded fonts as suggested here using fontfaceobserver, 按照此处的建议使用fontfaceobserver加载字体,
  • Reviewed my css files, reduced amount of inline-css in js files to minimal 检查了我的CSS文件,将js文件中的内联CSS数量减少到最小

my current pagespeed is Medium(72) and Good(85) and PageSpeed Insights suggests to remove JS file which are blocking download (this is my main.js from react) and optimize CSS delivery (which is my main.css), and to make use of browser-caching (which I think is not the case here). 我目前的pagespeed是Medium(72)和Good(85),而PageSpeed Insights建议删除阻止下载的JS文件(这是我的main.js进行响应),并优化CSS交付(这是我的main.css),并利用浏览器缓存(我认为情况并非如此)。

I seen similar questions and I tried to load pages as chunks using code-splitting (from this tutorial ) but it only reduced the pagespeed from what I have now, to 40-70 for mobile and for desktop respectively which makes no sense to me because why smaller chunks of code would do this? 我看到了类似的问题,并且尝试使用代码拆分将页面加载为大块(来自本教程 ),但这只会将页面速度从现在的速度降低到移动和台式机的40-70,这对我来说毫无意义,因为为什么较小的代码块会这样做? I also tried different approaches of react-router code-splitting but they didn't help to improve pagespeed at all, even worsen it. 我还尝试了反应路由器代码拆分的不同方法,但它们根本没有帮助提高页面速度,甚至使页面速度更糟。

I thought the issue might be that I 我以为问题可能是我

@import "material-components-web/material-components-web";

In my index.scss which is pretty heavy itself, I tried to import separate MDC packages but it didn't affected page speed at all. 在我自己的index.scss中,我尝试导入单独的MDC程序包,但它根本没有影响页面速度。 What can be done to reach desired 90+ pagespeed in my case? 在我的情况下,要达到90以上的页面速度应该怎么做? Thank you! 谢谢!

Well create-react-app is a broad starter project, meaning it is made with different things in mind, and with that, come ~50-100 dependencies which most of them you probably don't need/use. 好吧, create-react-app是一个广泛的入门项目,这意味着它是根据不同的东西制作的,因此, 大约有50-100个依赖项 ,其中大多数您可能不需要/不使用。 Such a simple tool comes with it's downsides like this. 如此简单的工具附带了它的缺点。 If you are a beginner it is a very awesome tool to use, if you are advanced you'll see you have to eject to make more advanced config changes. 如果您是初学者,那么它是一个非常出色的工具,如果您是高级用户,将会看到您必须退出以进行更多高级配置更改。

If you really need to tweak it for you every single need, you need to eject, then start by cutting off dependencies that you don't need, but if you are a beginner, I'd say stick with it. 如果您确实需要针对每种需求进行调整,则需要退出,然后从切断不需要的依赖项开始,但是如果您是初学者,我会坚持使用它。

I know this isn't a precise answer to your question, but broad questions receive broad answers :) 我知道这不是您问题的精确答案,但是广泛的问题会得到广泛的答案:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM