All language subtitles for 006 Running a Test Build & Reducing Code Size_Downloadly.ir_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,120 --> 00:00:05,850 So now that we did add environment variables 2 00:00:05,850 --> 00:00:08,150 before we get to deployment, 3 00:00:08,150 --> 00:00:11,690 it's time to do a test build on our local machine 4 00:00:11,690 --> 00:00:13,810 and see if we're happy. 5 00:00:13,810 --> 00:00:16,450 And for this, I opened the terminal again. 6 00:00:16,450 --> 00:00:18,820 and now when I wanna run this build command 7 00:00:18,820 --> 00:00:22,340 which builds our application for production. 8 00:00:22,340 --> 00:00:24,250 And if you run NPM run build 9 00:00:24,250 --> 00:00:27,740 this production optimized build is being produced. 10 00:00:27,740 --> 00:00:31,930 And we also get useful information shown to us here. 11 00:00:31,930 --> 00:00:36,130 We see, for example, which pages are built for the server, 12 00:00:36,130 --> 00:00:39,410 which pages are 100% static, 13 00:00:39,410 --> 00:00:41,270 this with the empty.here 14 00:00:41,270 --> 00:00:43,520 and which pages are dynamic 15 00:00:43,520 --> 00:00:46,760 but were statically pre-generated. 16 00:00:46,760 --> 00:00:49,630 And we see that output here and that's all looking good. 17 00:00:49,630 --> 00:00:52,597 We got the starting page pre-generated, 18 00:00:52,597 --> 00:00:56,250 our 404 was added for us automatically. 19 00:00:56,250 --> 00:00:58,810 Contact page is 100% static 20 00:00:58,810 --> 00:01:01,800 because we don't fetch any dynamic data here. 21 00:01:01,800 --> 00:01:05,170 And then we got posts and deposed detail pages, 22 00:01:05,170 --> 00:01:07,363 which were also pre-generated. 23 00:01:08,480 --> 00:01:10,960 But here we see an issue. 24 00:01:10,960 --> 00:01:14,960 This is red because this posts detailed page. 25 00:01:14,960 --> 00:01:17,170 These pages are too big, 26 00:01:17,170 --> 00:01:20,420 they contain too much JavaScript. 27 00:01:20,420 --> 00:01:23,620 We could deploy it, it wouldn't break 28 00:01:23,620 --> 00:01:25,470 but this is a clear indicator 29 00:01:25,470 --> 00:01:28,840 that we might be doing something in those pages 30 00:01:28,840 --> 00:01:30,500 which is not optimal. 31 00:01:30,500 --> 00:01:33,260 We might be shipping too much code. 32 00:01:33,260 --> 00:01:34,870 And very often that means 33 00:01:34,870 --> 00:01:37,560 that you're using some third party package, 34 00:01:37,560 --> 00:01:40,830 some third party library that is too big. 35 00:01:40,830 --> 00:01:43,420 So therefore, before we deploy something, 36 00:01:43,420 --> 00:01:45,540 let's fix this issue. 37 00:01:45,540 --> 00:01:49,030 And for this, let's have a look at the detail page. 38 00:01:49,030 --> 00:01:52,930 Now this slag page here is certainly not too big. 39 00:01:52,930 --> 00:01:55,260 It doesn't have a lot of code. 40 00:01:55,260 --> 00:01:58,060 We also can ignore any code, 41 00:01:58,060 --> 00:02:02,830 which is only needed in getStaticProps or getStaticPaths. 42 00:02:02,830 --> 00:02:06,710 That code will only execute during the build process 43 00:02:06,710 --> 00:02:08,880 and on the server anyways. 44 00:02:08,880 --> 00:02:11,330 That will never end up on the client 45 00:02:11,330 --> 00:02:16,330 and the code here this size refers to the client side code. 46 00:02:17,000 --> 00:02:19,510 So we can't ignore the server side code. 47 00:02:19,510 --> 00:02:21,620 So this component should be fine. 48 00:02:21,620 --> 00:02:24,603 Therefore, let's explore the post content component. 49 00:02:25,480 --> 00:02:29,090 Here, we all don't have too much code on our own 50 00:02:29,090 --> 00:02:33,720 but we are using a couple of third party packages 51 00:02:33,720 --> 00:02:37,653 react markdown, and this syntax highlighter. 52 00:02:38,490 --> 00:02:41,810 And now you would have to dig into those packages 53 00:02:41,810 --> 00:02:44,150 and find out how big they are. 54 00:02:44,150 --> 00:02:47,440 And I can tell you that our problem here 55 00:02:47,440 --> 00:02:49,900 is react syntax highlighter. 56 00:02:49,900 --> 00:02:52,120 This is huge. 57 00:02:52,120 --> 00:02:57,120 If you visit the react syntax highlighter GitHub repository, 58 00:02:57,150 --> 00:02:58,850 then you actually find out 59 00:02:58,850 --> 00:03:01,600 that they tell you that it's quite big 60 00:03:01,600 --> 00:03:04,060 and that they offer a light build 61 00:03:04,060 --> 00:03:07,120 because the react syntax highlighter 62 00:03:07,120 --> 00:03:09,793 can have a very large footprint. 63 00:03:11,210 --> 00:03:14,420 But the solution is simple, we can use the light build 64 00:03:14,420 --> 00:03:17,500 basically as it is described down there. 65 00:03:17,500 --> 00:03:19,840 The difference between the light version 66 00:03:19,840 --> 00:03:21,640 and the version we're currently using 67 00:03:21,640 --> 00:03:24,020 is that this version out of the box 68 00:03:24,020 --> 00:03:26,190 supports syntax highlighting 69 00:03:26,190 --> 00:03:30,020 for all possible programming languages. 70 00:03:30,020 --> 00:03:33,470 That might sound nice, but it is quite redundant 71 00:03:33,470 --> 00:03:36,280 and it adds a lot of JavaScript code. 72 00:03:36,280 --> 00:03:38,010 In reality, 73 00:03:38,010 --> 00:03:43,010 we are probably not going to include C++ code snippets here 74 00:03:43,950 --> 00:03:47,210 if we are blogging about web development. 75 00:03:47,210 --> 00:03:49,230 And hence using the light build 76 00:03:49,230 --> 00:03:53,090 and explicitly stating the languages we wanna support 77 00:03:53,090 --> 00:03:55,800 is probably the better choice here. 78 00:03:55,800 --> 00:03:57,400 And that's what we can do. 79 00:03:57,400 --> 00:04:02,223 We can also import the styling in a slightly optimized way. 80 00:04:03,400 --> 00:04:08,400 So therefore what I'll do here is I'll import PrismLight 81 00:04:08,460 --> 00:04:11,140 as Syntax Highlighter, instead of prism 82 00:04:12,290 --> 00:04:15,160 and I'll import my styles differently 83 00:04:15,160 --> 00:04:19,630 by diving into style/prism/atom-dark 84 00:04:19,630 --> 00:04:23,030 and then importing atomDark like this. 85 00:04:23,030 --> 00:04:26,130 This will also only import that style then 86 00:04:26,130 --> 00:04:27,643 and no other styles. 87 00:04:28,560 --> 00:04:30,910 And now we need to import the languages 88 00:04:30,910 --> 00:04:32,750 which we wanna support. 89 00:04:32,750 --> 00:04:34,690 And we do this by importing 90 00:04:34,690 --> 00:04:39,690 from react-syntax-highlighter/ dist/cjs/languages/prism/ 91 00:04:43,970 --> 00:04:45,510 and then we have different options 92 00:04:45,510 --> 00:04:47,783 like JavaScript for example. 93 00:04:48,770 --> 00:04:53,770 And then we could import this as js, whatever you want. 94 00:04:54,350 --> 00:04:56,960 And we could, of course also duplicate this. 95 00:04:56,960 --> 00:04:57,793 And for example, 96 00:04:57,793 --> 00:05:02,100 all the import css if we wanna support this as well. 97 00:05:02,100 --> 00:05:04,720 And you can simply add all the languages 98 00:05:04,720 --> 00:05:06,160 you wanna support. 99 00:05:06,160 --> 00:05:08,460 So all the languages which you'll use 100 00:05:08,460 --> 00:05:10,423 in your code snippets typically. 101 00:05:11,380 --> 00:05:14,390 Then you just need to register those languages 102 00:05:14,390 --> 00:05:18,960 simply by calling SyntaxHighlighter.registerLanguage 103 00:05:18,960 --> 00:05:23,040 and then the identifier, for example js 104 00:05:23,040 --> 00:05:24,230 that's the identifier 105 00:05:24,230 --> 00:05:28,703 which I also use in my markdown code here. 106 00:05:29,860 --> 00:05:32,893 So we need to import that identifier. 107 00:05:34,120 --> 00:05:38,830 And then as a second argument, that imported language 108 00:05:39,830 --> 00:05:43,380 and I'll repeat that for css here. 109 00:05:43,380 --> 00:05:47,223 And with that, we should have a much lighter footprint. 110 00:05:48,580 --> 00:05:52,960 If we now run NPM run build again 111 00:05:52,960 --> 00:05:56,750 with those changes applied, it will build our site again 112 00:05:56,750 --> 00:05:59,350 and produce all those files again. 113 00:05:59,350 --> 00:06:03,280 And now we'll see that this is much smaller. 114 00:06:03,280 --> 00:06:08,280 It shrank from 320 kilobytes to 114 kilobytes. 115 00:06:09,520 --> 00:06:11,105 And it's also worth noting 116 00:06:11,105 --> 00:06:15,230 that these sizes are before compression, 117 00:06:15,230 --> 00:06:18,610 but Node.js will compress these files. 118 00:06:18,610 --> 00:06:22,140 So once they are served, they are much smaller 119 00:06:22,140 --> 00:06:24,150 and therefore that should be fine. 120 00:06:24,150 --> 00:06:27,160 Now let's also test if that looks good though. 121 00:06:27,160 --> 00:06:29,120 So let's start the def server 122 00:06:29,120 --> 00:06:32,270 to see if our change has broke something 123 00:06:32,270 --> 00:06:34,090 and go to Posts, 124 00:06:34,090 --> 00:06:37,020 and then that post, which has that code snippet 125 00:06:37,020 --> 00:06:40,683 and that still looks all right here if we have a look at it. 126 00:06:41,690 --> 00:06:43,640 So that is working. 127 00:06:43,640 --> 00:06:45,980 Now we have that syntax highlighting 128 00:06:45,980 --> 00:06:48,720 but with a smaller footprint. 129 00:06:48,720 --> 00:06:51,920 And that's why checks like this are important 130 00:06:51,920 --> 00:06:54,760 and why you should always validate your code 131 00:06:54,760 --> 00:06:56,870 and see if you can improve it. 132 00:06:56,870 --> 00:07:00,640 And even here you might find over third-party packages 133 00:07:00,640 --> 00:07:02,820 which have a even smaller footprint. 134 00:07:02,820 --> 00:07:06,800 You might find different ways of highlighting syntax. 135 00:07:06,800 --> 00:07:10,130 There might still be ways of improving these even more 136 00:07:10,130 --> 00:07:11,930 but we already gained a lot here 137 00:07:11,930 --> 00:07:14,640 and we now have a size that's okay. 138 00:07:14,640 --> 00:07:16,480 And therefore now with that, 139 00:07:16,480 --> 00:07:19,633 I think we're ready to actually deploy this. 10810

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.