javascript - Why my nextjs app doesn't work on Safari? - Stack Overflow

I'm developing a web app using nextjs. Everything works just fine on every browser, except for Saf

I'm developing a web app using nextjs. Everything works just fine on every browser, except for Safari on Mac. This is what I got when I open the developer console:

Only on Mac that this is happening, it can still run normally on an iPhone. Does anyone have an idea why this is happening?

I'm developing a web app using nextjs. Everything works just fine on every browser, except for Safari on Mac. This is what I got when I open the developer console:

Only on Mac that this is happening, it can still run normally on an iPhone. Does anyone have an idea why this is happening?

Share Improve this question asked Sep 23, 2021 at 5:30 William.DWilliam.D 1251 silver badge10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

The IntersectionObserver API is not available on Safari v3.1-12. Either you or any of your libraries is using this API. To make it work on older versions of Safari, you need to polyfill it. Something like this should do the job for Safari v6+:

// pages/_app.jsx

import Script from 'next/script';

const App = ({ Component, pageProps }) => (
  <>
    <Script
      src="https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver"
      strategy="beforeInteractive"
    />
    <Component {...pageProps} />
  </>
);

export default App;

References:

  • https://caniuse./intersectionobserver
  • https://nextjs/docs/basic-features/supported-browsers-features#custom-polyfills
  • https://github./w3c/IntersectionObserver/tree/main/polyfill
  • https://nextjs/docs/basic-features/script#loading-polyfills
  • https://nextjs/docs/advanced-features/custom-app

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745398642a4625998.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信