Confusion about Lighthouse report of unused JS for react devtools chrome extension - reactjs

When I run Lighthouse for the project I am working on, I get
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js
as no1 causer of unused JS.
How is that making sense from a performance optimization perspective?
I can't control what extensions the user runs in his browser.
I also can't find anything about the React dev tools in the project.
Would highly appreciate if someone could shed some light on that issue.

I found the issue is because the file of the devTools is installed when the page is loading... and it is useless in production mode.
So go to the extension and right click on it.
Then go to the manage extensions.
Then find the "Allow this extension to read and change all your data on websites you visit" change it to "on click".

Related

Is it impossible to use react dev tools in a Chrome extension dev tools?

This makes the workflow a lot harder. Is there a way to use react dev tools?
I also notice constantly that the extension dev tools take some time to load, like 1 to 2s, and because of that, it misses network requests... is there a way to speed it up? I mean, speed up the development workflow, maybe some way to let the extension use more memory? the first few requests do not show in the network tab, but they are sent to the server.
I'm talking about the dev tools that open when you click on the (service worker) link in the chrome://extensions/ tab or when you open the **
** and do right click > inspect
The standalone version of React Devtools works https://github.com/facebook/react/tree/main/packages/react-devtools
Since you can't load the script from localhost you will have to include it in your extension.
To do that, go to http://localhost:8097 (or wherever your react devtools is running), save the JS to a file in your Chrome extension folder and add that with a script tag to your html.
Be sure to remove it before publishing.
I also notice constantly that the extension dev tools take some time to load, like 1 to 2s, and because of that, it misses network requests... is there a way to speed it up?
You can try to use the Incognito Mode. There will be no extensions used. So, it will not affect your network requests.

React extension is missing in Dev tools

I am trying to get my react extension working for local development, but "Components" and "Profiler" is missing in the Chrome developer tools. This only happens for local development, any other production code is displaying the two tabs in the developer tools as expected. I was wondering if this can be resolved somehow? I triple checked if the tabs are hidden on that occasion, and they are not. As said, this only happens for development version. When I click on the extension, I get the following message:
This page is using the development build of React. 🚧
Note that the development build is not suitable for production.
Make sure to use the production build before deployment.
Open the developer tools, and "Components" and "Profiler" tabs will appear to the right.
Based on this information I should have the tabs displayed.
When I go to a production app and click on the React extension, I can see the following displayed:
This page is using the production build of React. ✅
Open the developer tools, and "Components" and "Profiler" tabs will appear to the right.
And I also see those two tabs without a problem.
Any idea why this would happen? I searched for a solution, but did not encounter one. The only thing I found was someone mentioning you need to set the environment variable REACT_APP_ENV. I tried to set this value in the .env file where I defined REACT_APP_ENV='dev' as well as REACT_APP_ENV='development'. It did not resolve the issue, even with application and browser restart.
This happened to me as well. Looks like a bug in Chromium, but a temp solution is:
Change the chrome DevTools theme, only once it is required.
Now open devtools, you find the extension tab in DevTools.
You can again change the theme whatever you want to keep and this will fix your problem.
Check this out:
https://github.com/facebook/react/issues/19002#issuecomment-637462179
Was having the same issue, the Components and Profiler tabs weren't showing up, so I tried changing the theme as suggested by BobTheBuilder, that didn't work, so tried setting the debug levels to Default + Verbose (in addition to the others) in the console and they finally showed up.
The steps that helped me:
Remove React Developer Tools extension
Install React Developer Tools extension
Open a brand new tab containing react app
Open Dev Tools
React Developer Tools should be available
I had the same issue where Components and Profiler tabs were not showing. What worked for me was to open up the DevTools settings and to click the 'Restore defaults and reload' button (under the 'Sync' heading).
The steps that worked for me
Open chrome extensions
Disable the react dev tools extension
Enable the react dev tools extension
Enable Developer mode
Refresh target page
Where steps 1 and 2 are the little slide control at the bottom right of the extension in the extension manager.
Step 4 is the slider in the top right above all the extensions in the manager.

No Link to source-code in Chrome Devtools for React components

I use create-react-app 16.["react": "^16.8.4", "react-scripts": "^2.1.8"]
I read the blog on profiling react performance by Ben Schwarz using Chrome Dev tools:
https://building.calibreapp.com/debugging-react-performance-with-react-16-and-chrome-devtools-c90698a522ad
He recommends to export your JS with source-maps.
When he does a performance trace, and clicks on a given react component in the User Timing section, specific component information shows in the Bottum-Up section with ** blue links to the source code** on the right hand side. This links don`t show, when I click on React components. When I click on components like for instance Evaluate Script, the blue links on the right hand side show.
Isn`t source mapping supposed to work "out-of-the-box" with create-react-app 16 in development.
I want to source-map only in development using Chrome Dev tools. Source mapping is activated in the Chrome Browser. What am I missing?
Thx in advance
P.S.:Since I haven`t got 10 reputation points I´m not suppose to use screenshots, which in this case made things not quite easy. I hope I managed to explain my problem sufficiently, though.
The Source Files for Debugging will be available under your localhost:3000 in the Chrome devtools.
We always tend to search under webpack://
Changes have been made to the newer versions I beleive
We always tend to search under webpack://
Changes have been made to the newer versions I beleive
Could you check the file
node_modules/react-scripts/config/webpack.config.js
Search there for the sourceMap and sourceMaps, and see if that is ok for you.
You can copy that file like "_original", and then set
sourceMaps: true,
in all ocurrences. After that, completely stop the app, and then start it again.
Is that working now?
To verify which sourceMap is working or not, add the sources to workspaces and check for the green dot:
https://developers.google.com/web/tools/chrome-devtools/workspaces/

debug react native app from chrome on windows machine

I started exploring react-native. One thing which I want is should able to debug my app from chrome. I am having prior experience to cordova. Cordova renders app in chrome web view. I understand that with react-native it is not possible because react-native doesn't render app on web view.
There is an option react-native "debug in chrome". When I click this option, attached screenshot is getting opened. I enabled "pause on exception."
But nothing is happening. I am unable to see my app code at all.
I like to do step by step debugging. Is it possible? If so can some one tell how to do this?
You can definitely examine the source code, set breakpoints, etc in Chrome.
In the Sources menu, select debuggerWorker.js and then you should be able to see your project tree.
Any console.log in your code will print to the browser too. But I find the breakpoint inspection most helpful.
this is simple as you were doing in cordova.
try to put debugger; statement in your code while in debug mode.
It will set the breakpoint and you can then debug your application. No need to find out your files in debuggerWorker.js

How do I stop Angular from loading the .angular.min.js.map file when pulling Angular from a CDN?

I am working on a website which loads AngularJS from a CDN, and along with Angular it loads a 284KB map file (angular.min.js.map), which I understand is for debugging.
I don't want to debug, this is going into production, and 284KB is a lot! How do I stop this file from loading?
I can't edit the file (CDN), and it doesn't matter what my Google Chrome options are, I can't advise others to change their settings to use the website I am working on.
Thanks
According to http://blog.teamtreehouse.com/introduction-source-maps
The developer tools will only load this file if support for source maps is enabled and the developer tools are open.
So any impact will only be felt if someone opens their developers tools, which I suspect is acceptable, as in that case ability to debug it more important than download speed/size.
Within Google Chrome's inspector, have you unticked 'Enable JavaScript source maps' in Settings > General?
I think your dev setup is trying to pull the source map file in regardless, for others without this option ticked in Chrome's inspector it won't be a problem.
Don't worry about the source map files for production.
Only if a user has chrome dev tools or other source map compatible browser tools running will they request and download the source map file/s.

Resources