Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The module increasing TBT. Need help #1165

Closed
Croodo opened this issue May 9, 2021 · 7 comments
Closed

The module increasing TBT. Need help #1165

Croodo opened this issue May 9, 2021 · 7 comments

Comments

@Croodo
Copy link

Croodo commented May 9, 2021

I made an app with up to 17 languages, this is causing an issue with TBT(Total Blocking Time) [Which causing a lower score on pageSpeed].

nuxt.config

modules: [
   "@nuxtjs/axios",
      [
     "nuxt-i18n",
     {
       detectBrowserLanguage: {
         useCookie: true,
         alwaysRedirect: true
       }
     }
   ]
 ],

i18n: {
   seo: true,
   strategy: "prefix_except_default",
   locales: [
     {
       code: "es",
       iso: "es",
       file: "es.js",
       name: "Español",
     },
     {
       code: "fr",
       iso: "fr-FR",
       file: "fr.js",
       name: "Français"
     },
     {
       code: "cn",
       iso: "zh-CN",
       file: "cn.js",
       name: "中文(简体)"
     },
     {
       code: "de",
       iso: "de-DEU",
       file: "de.js",
       name: "Deutsch"
     },
     {
       code: "br",
       iso: "pt-BR",
       file: "br.js",
       name: "Português"
     },
     {
       code: "id",
       iso: "id",
       file: "id.js",
       name: "Indonesia"
     },
     {
       code: "in",
       iso: "hi",
       file: "in.js",
       name: "हिन्दी"
     },
     {
       code: "it",
       iso: "it-IT",
       file: "it.js",
       name: "Italiano"
     },
     {
       code: "jp",
       iso: "ja-JP",
       file: "jp.js",
       name: "日本語"
     },
     {
       code: "tw",
       iso: "zh-TW",
       file: "tw.js",
       name: "中文(繁體)"
     },
     {
       code: "kr",
       iso: "ko-KR",
       file: "kr.js",
       name: "한국어"
     },
     {
       code: "nl",
       iso: "nl",
       file: "nl.js",
       name: "Nederlands"
     },
     {
       code: "pl",
       iso: "pl",
       file: "pl.js",
       name: "Polski"
     },
     {
       code: "ru",
       iso: "ru-RU",
       file: "ru.js",
       name: "Pусский"
     },
     {
       code: "tr",
       iso: "tr-TR",
       file: "ru.js",
       name: "Türkiye"
     },
     {
       code: "vn",
       iso: "vi-VN",
       file: "vn.js",
       name: "Tiếng Việt"
     },

     {
       code: "en",
       iso: "en",
       file: "en.js",
       name: "English",
       isCatchallLocale: true,
     }
   ],
   baseUrl: "https://www.apkdojo.com",
   lazy: true,
   langDir: "lang/",
   defaultLocale: "en",
   vueI18n: {
     fallbackLocale: "en"
   }
 },

Any solution to this, which can help me to reduce TBT?
Need a faster method to use i18n, please help.

@Croodo Croodo changed the title The module increasing TBT The module increasing TBT. Need help May 9, 2021
@rchl
Copy link
Collaborator

rchl commented May 9, 2021

Probably seeing #690 due to large amount of routes.

@Croodo
Copy link
Author

Croodo commented May 9, 2021

Yeah got that, This is happening because of a large number of routes generated but can't find any clue how to stop generating all locales routes (unnecessary routes for the page).

@rchl
Copy link
Collaborator

rchl commented May 10, 2021

Do you have any unnecessary routes? What do you consider unnecessary?

The way this module works is it creates a separate route for each locale so you end up with "number of page routes * number of locales". It's all necessary from this module's point of view.

The alternative would be to use the "no_prefix" strategy so that no additional routes will be created but that of course has its cons.

Or maybe you can utilize the dynamic routes so that you have a single route that handles most of the pages dynamically...

It's not really a bug in this module so I can't help you otherwise.

@Croodo
Copy link
Author

Croodo commented May 10, 2021

OK got it. But is there any way that I can try to optimize execution time?

@rchl
Copy link
Collaborator

rchl commented May 10, 2021

See nuxt/nuxt#7473

On your side you probably can only do what I've outlined above.

@Croodo
Copy link
Author

Croodo commented May 10, 2021

OK, Thanks for the reference. Let me try it.

@rchl
Copy link
Collaborator

rchl commented May 12, 2021

Closing as duplicate of #690

@rchl rchl closed this as completed May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants