Giter Club home page Giter Club logo

Comments (2)

agcty avatar agcty commented on June 12, 2024

Thanks for your comment! As of next.js 10.2.0 google fonts are automatically optimized already: https://nextjs.org/blog/next-10-2#automatic-webfont-optimization

from nextjs-advanced-starter.

sebmellen avatar sebmellen commented on June 12, 2024

Yes, although in the case of Next.js automatically optimizing webfonts, it's important to note the optimized stylesheet is still calling external resources (the .woff/.woff2 files) which are loaded from external sources. For example, the default Inter stylesheet loads the normal 400pt Inter .woff file from a URL that looks like this: https://fonts.gstatic.com/s/inter/v3/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZxhjp-Ek-_EeAmM.woff. These requests are repeated for each included font-weight and font-style.

Though Google does a great job at optimizing, these are still external network requests. When using PWAs or running Next.js apps only on local networks (not common, but I have seen it done), having fonts available locally becomes important. Some small amount of your "advanced" users may need such a feature — for example, I am adding this on my end.

Also, for use-cases like running Next.js inside Electron, where the browser is known to support variable fonts, using a variable font (which Inter supports) is another way to eliminate 10+ network requests for full font-weight support. (These variable fonts also have the added advantage of supporting in-between font-weight values, like font-weight: 420.)

Next.js works great with local fonts as well! See https://kirazhang.com/posts/nextjs-custom-fonts for an idea.

If undesired, this would also be easy to remove (just by deleting one folder) and it would also have no impact on performance if the user does not remove it. Plus, the Google Font plugin would still be the default, but the README could note the option of using local fonts.

Again — not my repo — so I'm not trying to force anything! I just think it might be worth considering :). Thank you!

from nextjs-advanced-starter.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.