1

recently I've added the react devtools backend extension which I noticed is causing 2 additional component renders (I'm using Nextjs framework) which isn't so much of a problem in development however when published this would really hit the websites performance and I'm trying to disable it, and to do so I've adding the following code in _document.js file:

import { Html, Head, Main, NextScript } from "next/document";
import Script from "next/script";

export default function Document() {
    return (
        <Html lang="en-US">
            <Head />
            <body>
                <Main />
                <NextScript />
                <Script
                    strategy="beforeInteractive"
                    dangerouslySetInnerHTML={{
                        __html: `if(typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object'){ __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {}; }`,
                    }}
                />
            </body>
        </Html>
    );
}

But hasn't changed anything.

Daniel_Kamel
  • 610
  • 8
  • 29

0 Answers0