React Server Components vs Client Components

Piyush Garg
5 Nov 202327:30

Summary

TLDRThis video script delves into the concept of React Server Components, explaining their role and how they differ from traditional client-side components. It discusses the evolution from React 18 and Next.js 13.4, highlighting the benefits of server-side rendering for improved performance and user experience. The script guides viewers on leveraging server components for faster initial page loads and reduced JavaScript bundle sizes, ultimately enhancing the overall website speed and interactivity.

Takeaways

  • 🌟 The video introduces the concept of React Server Components, a new feature that allows parts of a React application to be rendered on the server-side.
  • 🔍 It clarifies the difference between server-side rendering and client-side rendering in React, explaining how server components can improve performance and user experience.
  • 🛠️ The video promises a practical implementation of server components, guiding viewers through the process of integrating them into their projects.
  • 🚀 For React developers aiming to enhance app performance, understanding server components is crucial, as they can significantly reduce the time to interactivity.
  • 🔑 The script discusses the benefits of server components, such as reducing the JavaScript bundle size sent to the client, which can speed up page load times.
  • 📚 It explains the architecture of React with server components, emphasizing how it differs from traditional React applications that rely on client-side rendering.
  • 💡 The video highlights the importance of identifying which components should be server components and which should remain client-side for optimal performance.
  • 🛑 The script addresses common issues with traditional React apps, such as long loading times and blank screen problems, and how server components can help mitigate these.
  • 🔄 The concept of 'hydration' is introduced, explaining how React integrates server-rendered content with client-side JavaScript to create interactive pages.
  • 🔍 The video provides insights into optimizing the JavaScript bundle size by selectively rendering components on the server or client, leading to faster interactivity.
  • 🛠️ It concludes by emphasizing the need for developers to be strategic in their use of server components to enhance the overall user experience without compromising on app functionality.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is about React Server Components, explaining what they are, how they work, and their differences from traditional React client components.

  • Why are React Server Components introduced in the video?

    -React Server Components are introduced to address certain performance issues and to optimize the user experience by reducing the load on the client-side and enhancing the rendering process on the server-side.

  • What is the difference between Server-Side Rendering and Server Components as discussed in the video?

    -Server-Side Rendering refers to the process of rendering a complete page on the server and sending it to the client, while Server Components are a part of React's architecture that allows certain components to be rendered on the server, without necessarily rendering the entire page.

  • How does the video explain the concept of 'First Paint' in the context of React applications?

    -The video explains 'First Paint' as the point in time when the user sees some visible content on the screen, which may initially be just the shell of the page with loading indicators, before the actual interactive content is loaded.

  • What is the problem with having a large JavaScript bundle size as mentioned in the video?

    -A large JavaScript bundle size can lead to increased load times, which can negatively impact the user experience by making the application feel slow and potentially causing users to leave the site before it fully loads.

  • How do React Server Components help in reducing the JavaScript bundle size sent to the client?

    -React Server Components help by only sending the necessary client components to the client, while the server components remain on the server. This means the JavaScript related to server components does not need to be downloaded by the client, reducing the overall bundle size.

  • What is 'Hyddration' in the context of React applications as discussed in the video?

    -Hyddration in React refers to the process where the client-side React application attaches event listeners and makes the server-rendered page interactive after the initial rendering is done.

  • Why is it important to differentiate between Server Components and Client Components in a React application?

    -Differentiating between Server and Client Components is important for optimizing performance. Server Components can be rendered on the server without sending their JavaScript to the client, reducing the load on the client and improving the initial load time and interactivity of the application.

  • What is the role of Pages Router in the context of the video?

    -Pages Router is used in the video to demonstrate the implementation of Server Components in a Next.js application, showing how pages and components are structured and how the routing works with server-side rendering support.

  • How does the video suggest optimizing the JavaScript bundle for components that do not require interactivity?

    -The video suggests that for components that do not require interactivity, such as those only displaying data without any interactive elements, they can be marked as Server Components to avoid sending unnecessary JavaScript to the client, thus optimizing the bundle size.

  • What is the potential impact of using Server Components on the user experience according to the video?

    -According to the video, using Server Components can improve the user experience by reducing the initial load time and making the application more interactive faster, as it minimizes the amount of JavaScript that needs to be downloaded and processed on the client-side.

Outlines

00:00

🌟 Introduction to React Server Components

The paragraph introduces the topic of React Server Components, emphasizing their significance for developers looking to enhance their applications' performance. It discusses the evolution of server components in React, starting from React 18's introduction of concurrent features to Next.js 13.4's implementation of server components. The speaker highlights the importance of understanding the difference between server-side rendering and client-side rendering in React, and how server components can optimize the user experience by reducing load times and eliminating blank screens during initial page loads.

05:01

🚀 Enhancing User Experience with Server Components

This section delves into the problems faced with traditional React client components, such as long loading times and blank screens, which can lead to high bounce rates. The speaker then contrasts this with the benefits of server components, which can perform initial rendering on the server, thereby reducing the time users see blank screens. The discussion includes the concept of 'first paint', where the page starts to become visible to the user, and how server components can expedite this process. The paragraph also touches on the technical aspects of implementing server components and the potential for a more seamless and interactive user experience.

10:03

🛠️ Practical Implementation of Server Components

The speaker provides a practical walkthrough of implementing server components in a React application. They discuss the process of setting up a development environment with Next.js, creating a basic page with server components, and the differences in how these components are handled compared to client components. The paragraph explains the default behavior of components within the Next.js 'pages' directory as server components and the implications of this for rendering and hydration processes. It also touches on the challenges of integrating interactive elements like buttons within server components and the solutions available.

15:03

🔍 Deep Dive into Server Component Architecture

This section offers an in-depth analysis of the architecture and functionality of server components. The speaker explains how server components can pre-render pages on the server, stream HTML, and only after that, download the necessary JavaScript for client-side interactions. They discuss the optimization of the hydration process due to the reduced size of the JavaScript bundle, which contains only the client components. The paragraph also addresses the trade-offs between server and client components, such as the increased server load during rendering and the benefits of faster interactive page times.

20:04

🎯 Optimizing Component Choice for Performance

The focus of this paragraph is on the strategic decision-making process for choosing whether a component should be a server component or a client component. The speaker illustrates this with examples from an e-commerce website, explaining how certain components like product cards can be optimized by selectively rendering parts on the server and parts on the client. The discussion highlights the importance of this choice in influencing the overall performance and user experience, as well as the potential for reducing the JavaScript bundle size and speeding up the page load times.

25:05

🌐 Practical Example of Server vs. Client Components

In this segment, the speaker provides a practical coding example to demonstrate the difference between server and client components. They show how to create a simple Next.js application with page routing and how components within the 'pages' directory are treated as server components by default. The paragraph includes a demonstration of adding an interactive button, the errors encountered when trying to add event handlers to server components, and the solution of converting the button to a client component to handle interactions. The speaker also discusses the implications of this on the JavaScript bundle size and the overall optimization strategy for a web application.

📚 Conclusion and Future Considerations

The final paragraph wraps up the discussion on server components, summarizing the key points and the benefits they offer for improving web performance. The speaker encourages viewers to like and subscribe for more content and hints at future videos that will cover advanced techniques. This section serves as a conclusion, reinforcing the importance of server components in modern web development and their role in enhancing user experience through faster load times and more efficient resource utilization.

Mindmap

Keywords

💡React Server Components

React Server Components are a feature introduced in React 18.4 that allows developers to render parts of a React application on the server. This is pivotal for the video's theme as it discusses optimizing web application performance. In the script, it is mentioned as a concept that came with React 18.4 and is central to the discussion on improving user experience by reducing load times.

💡Hyddration

Hydrating in the context of React refers to the process where the client-side JavaScript takes over the static HTML content rendered on the server and makes it interactive. The video script discusses how, with the introduction of server components, hydration can be more efficient, as the JavaScript bundle size is reduced, leading to faster interaction times.

💡Client Components

Client Components are parts of a React application that are meant to be rendered on the client side, typically involving interactivity and dynamic behavior. The script emphasizes the importance of distinguishing between server and client components to optimize the application's performance, as client components require JavaScript to be downloaded and executed on the client's browser.

💡Server-Side Rendering (SSR)

Server-Side Rendering is a technique where the server generates the HTML of a web page and sends it to the client, which is then displayed in the browser. The video discusses SSR as a method to improve the perceived performance of React applications by reducing the time users see a blank screen, enhancing the user experience.

💡First Paint

First Paint refers to the time when the user sees something rendered on the screen, which is a critical performance metric. The video script explains how React Server Components can help in optimizing the time to first paint by rendering the shell of the page on the server and sending it to the client.

💡JavaScript Bundle

A JavaScript Bundle in web development is a collection of JavaScript files that are combined and minified for efficient loading. The script discusses the impact of JavaScript bundle size on the application's load time and how server components can reduce the size of the bundle that needs to be sent to the client.

💡Interactivity

Interactivity in a web application refers to the ability of the page to respond to user inputs like clicks or keyboard events. The video script mentions that with server components, the page can become interactive faster because the necessary JavaScript for interactivity can be reduced or optimized.

💡Component Hydration

Component Hydration is the process where the static markup sent from the server is 'hydrated' by the client-side React, making it interactive. The video script explains that with server components, the hydration process can be more streamlined because the JavaScript required for this process is minimized.

💡React 18

React 18 is a major version release of the React library that introduced several new features, including Server Components. The video script mentions React 18 as the version that brought the concept of server components, which is a key topic in the video.

💡Next.js

Next.js is a popular React framework that facilitates server-side rendering and static site generation. The script refers to Next.js as the framework that supports the implementation of React Server Components, indicating its role in the evolution of server-rendered React applications.

💡User Experience (UX)

User Experience is the overall experience a user has while interacting with a system, particularly in this context, a web application. The video script discusses various aspects of React Server Components and how they contribute to improving the overall user experience by making web applications load faster and respond more quickly to user interactions.

Highlights

Introduction to React Server Components and their significance in enhancing performance and user experience.

Explanation of the concept of React Server Components that emerged in React 18 and Next.js 13.4.

Clarification of the difference between Server-Side Rendering and React Server Components.

How React Server Components work and their role in improving the initial load time of web applications.

The problem of blank screen issues and user experience concerns with traditional React client components.

The introduction of Next.js' Pages Router and its support for Server-Side Rendering.

Practical implementation of React Server Components in Next.js applications.

The impact of React Server Components on decreasing JavaScript bundle size and improving site speed.

Discussion on the hydration process of React components and its significance in interactivity.

How to identify which components should be server components and which should remain client components.

The benefits of using React Server Components for developers familiar with React, without needing to learn new technologies.

Addressing the problem of increasing JavaScript bundle size with the addition of features in applications.

Optimizing the user experience by reducing the time to interactive for web pages using React Server Components.

Technical demonstration of creating a user page with server components in Next.js.

Error handling and solutions when using event handlers within server components.

The importance of careful selection of server components to optimize JavaScript bundle size and site performance.

Conclusion summarizing the benefits and practical applications of React Server Components.

Transcripts

play00:00

हे एवरीवन वेलकम बैक वेलकम टू अनदर

play00:02

एक्साइटिंग वीडियो एंड इस वीडियो के अंदर

play00:04

हम बात करने वाले हैं रिक्ट सर्वर

play00:06

कंपोनेंट्स की यस तो इस वीडियो के अंदर हम

play00:09

ए टू जड समझने वाले हैं दैट सर्वर

play00:11

कंपोनेंट्स क्या होते हैं किस तरह से

play00:13

सर्वर कंपोनेंट्स वर्क करते हैं रिएक्ट के

play00:15

अंदर एंड नेक्स्ट के अंदर ऑफ कोर्स हम एक

play00:17

पीओ भी करेंगे हम प्रैक्टिकली

play00:19

इंप्लीमेंटेशन को भी देखेंगे एंड अगर तुम

play00:21

एक रिएक्ट डेवलपर या फिर एक नेक्स्ट

play00:23

डेवलपर बनना चाहते हो तो ये वीडियो

play00:24

तुम्हारे लिए सुपर डुपर इंपोर्टेंट है

play00:26

बिकॉज इसके अंदर हम इन डेप्थ में समझने

play00:28

वाले हैं दैट ली में क्या डिफरेंस है

play00:31

सर्वर साइड एंटरिंग में रिएक्ट सर्वर

play00:32

कंपोनेंट्स में और रिएक्ट क्लाइंट

play00:34

कंपोनेंट्स में तो इस वीडियो को एंड तक

play00:36

जरूर देखना एंड लेट्स स्टार्ट विद द

play00:37

वीडियो तो सबसे पहले जब रिएक्ट सर्वर

play00:39

कंपोनेंट्स का कंसेप्ट आया व्हिच इज लाइक

play00:42

आई नो दैट रिएक्ट 18 में आया था वो एंड

play00:43

नेक्स 13.4 में जब हमारे पास पप राउटर आया

play00:47

था तो हमारे पास कुछ सर्वर कंपोनेंट्स का

play00:48

कंसेप्ट था लेकिन स्टिल बहुत ज्यादा

play00:52

कंफ्यूजन है दैट व्हाट इज द डिफरेंस

play00:54

बिटवीन सर्वर साइड रेंडरिंग सर्वर

play00:56

कंपोनेंट्स तो एगजैक्टली है क्या तो इस

play00:58

वीडियो में उसको हम डिमिटी फाई करते और

play01:00

अच्छे से समझते हैं राइट तो इसके लिए मैं

play01:02

तुम्हें कुछ रिसोर्सेस भी प्रोवाइड करूंगा

play01:03

बट अभी के लिए इसको समझते हैं दैट पहले हम

play01:05

बात करते हैं दैट सिंपल जब हम सिंपल एक

play01:08

रिएक्ट की बात करते हैं जब हम रिएक्ट में

play01:10

सिंपल क्लाइंट कंपोनेंट्स बनाते हैं ओके

play01:13

तो मैं अभी कोई भी लाइक सर्वर साइड

play01:15

रेंडरिंग सर्वर कंपोनेंट्स की बात नहीं कर

play01:17

रहा लेट्स टॉक अबाउट सिंपल रिएक्ट ठीक है

play01:20

तो सिंपल रिएक्ट में जैसे हम आप तक

play01:21

क्लाइंट कंपोनेंट्स बनाते आ रहे थे तो इस

play01:24

पर्टिकुलर आर्किटेक्चर को समझने के लिए

play01:26

व्हाट वी विल डू इज वी विल टेक एन

play01:27

डायग्राम ठीक है तो यहां पर हमारे पास एक

play01:29

डायग्राम होने वाली है जिसमें हम मेजर्ली

play01:32

दो चीजों के बारे में बात करेंगे सो यू

play01:33

कैन अज्यू एक होता है सर्वर राइट वन इज

play01:36

सर्वर एंड सेकंड वन इज क्लाइंट राइट तो

play01:38

व्हाट यू कैन एज्यूम इज दैट ये जो ऊपर

play01:40

वाली लाइन है दिस इज़ फॉर द सर्वर तो यह

play01:42

पर्टिकुलर जो ब्लॉक है यह हम सर्वर के लिए

play01:44

यूज़ करेंगे अभी हम रिएक्ट की बात कर रहे

play01:46

हैं एंड सिमिलरली जो ये नीचे वाला ब्लॉक

play01:48

है इसको हम बात करेंगे क्लाइंट की ओके सो

play01:50

लेट्स अंडरस्टैंड दैट रिएक्ट अगर सिंपल

play01:52

रिएक्ट में हम बात कर रहे हैं तो सिंपल

play01:54

रिएक्ट किस तरह से वर्क करती है ओके सो

play01:56

व्हेन एवर यू विजिट अ वेब पेज सो लेट अस

play01:58

से दैट तुमने मेरी वेबसाइट को विजिट विजिट

play02:00

किया तो गलती से मैंने लोकल होस्ट को ओपन

play02:01

कर लिया तो लेट अस से दैट तुमने मेरी

play02:02

वेबसाइट को विजिट किया सो तुमने एक

play02:04

रिक्वेस्ट किया पकडे के ऊपर एंड एज्यूम

play02:08

करते हैं दैट ये जो पर्टिकुलर पेज है दिस

play02:10

इज बिल्ट विद सिंपल रिएक्ट ठीक है तो ये

play02:12

सिंपल रिएक्ट में बना है तो व्हाट हैपेंस

play02:15

इज व्हेन यू मेक अ विजिट टू

play02:29

सिंपल तुम्हारे पास एक जेएस बंडल का लिंक

play02:31

होगा ओके तो दैट मींस जब हमने सर्वर के

play02:34

ऊपर रिक्वेस्ट किया तो व्हाट हैपेंड हमारे

play02:37

सर्वर ने हमें एक जेएस बंडल का लिंक दे

play02:39

दिया एंड अब हमारा ब्राउजर क्लाइंट साइड

play02:42

पे इस पर्टिकुलर बंडल को करेगा डाउनलोड

play02:45

ओके

play02:46

दैट्ची जो बंडल है दिस इज़ लाइक अप्रॉक्स

play02:49

50 एब तो पहले तो यूज़र को वेट करना होगा

play02:51

फॉर लाइक फॉर दिस बंडल टू डाउनलोड राइट तो

play02:54

पहले 50mb का बंडल डाउनलोड होगा अ एंड

play02:56

जिसमें थोड़ा सा टाइम लगेगा एंड यहीं से

play02:59

एक प्रॉब्लम स्टार्ट होगी दैट फर्स्ट ऑफ

play03:01

ऑल यूजर के पास एक ब्लैंक स्क्रीन होगी

play03:03

बिकॉज़ अभी जेएस का जो बंडल है वो डाउनलोड

play03:05

हो रहा है ओके जब जावास्क्रिप्ट इस बंडल

play03:09

जब रिएक्ट का ये जो बंडल है जेएस बंडल है

play03:11

जब ये डाउनलोड हो जाएगा उसके बाद रिएक्ट

play03:14

क्या करेगी सिंपल रिएक्ट विल ट्राई टू री

play03:16

रेंडर विल ट्राई टू रेंडर नॉट री रेंडर

play03:19

रेंडर द शेल इस पर्टिकुलर पॉइंट का क्या

play03:20

मतलब ओके रेंडर शेल का क्या मतलब रेंडर

play03:23

शेल का मतलब होता है दैट इफ यू नो दैट तो

play03:25

रेंडर शेल स्टेज पे क्या होगा तुम्हारा जो

play03:27

पेज है जो हमारा रिएक्ट के अंदर जो पेज है

play03:29

वो स्क्रीन पे विजिबल हो जाएगा एंड वहां

play03:32

पर हर जगह हमारे पास क्या होंगे लोडिंग

play03:34

इंडिकेटर्स होंगे राइट सो फॉर एग्जांपल

play03:36

अगर हम किसी वेबसाइट को विजिट करते हैं तो

play03:38

हमें लाइक हेडर फुटर दिखना स्टार्ट हो

play03:39

जाएगा हमें पेज का एक लेआउट दिखना स्टार्ट

play03:41

हो जाएगा लेकिन अभी भी जो हमारा पेज का

play03:44

डाटा है वो फेच नहीं हुआ है ठीक है तो

play03:47

मतलब कि यूजर को पहले जेएस बंडल डाउनलोड

play03:49

करना पड़ा व्हिच इज वाज अबाउट 50 एब

play03:51

जिसमें यूजर जस्ट वेट कर रहा था एक खाली

play03:53

स्क्रीन की तरफ देख रहा था एंड उसके बाद

play03:55

ये जो रेंडर शेल है यह वाला प्रोसेस हुआ

play03:57

एंड रेंडर शेल ने क्या किया हमारे लो

play03:59

लोडिंग स्टेट्स को इनिश आइज कर दिया तो

play04:01

यानी कि अब यूजर को लोडिंग स्टेट्स दिख

play04:02

रही है ओके इस पॉइंट पे जितने भी हमारे

play04:05

यूज इफेक्ट्स हुक होंगे वो रन करेंगे एंड

play04:08

हमारे जो कंपोनेंट्स हैं वो एक-एक करके

play04:11

यहां पर एपीआई कॉल करना स्टार्ट करेंगे सो

play04:13

यू कैन से दैट यहां पर क्या होगा डीवी

play04:14

क्वेरीज होंगी राइट तो ये हमारे एक सर्वर

play04:16

पे होंगी तो यानी कि ये जब हमारा पेज

play04:19

रेंडर हो जाएगा फर्स्ट रेंडर होगा उसके

play04:21

बाद हमारे यूज इफेक्ट्स रन करेंगे एंड दे

play04:23

विल मेक अ डीबी क्वेरी नाउ यू कैन अजूम

play04:25

दैट हमारे जितने भी कंपोनेंट्स हैं लाइक

play04:27

हमारे बहुत सारे पैरेलल बैक एंड फोर्थ बैक

play04:29

एंड फोर्थ रिक्वेस्ट होंगी एंड ये डीबी

play04:31

क्वेरी कुछ अ ऑफकोर्स कुछ टाइम लेगी राइट

play04:33

आफ्टर द डीबी क्वेरी इज डन मतलब कि हमारा

play04:36

जो एपीआई कॉल है वो सक्सेसफुल रहा हमारे

play04:38

पास डाटा आ गया बैक एंड से उसके बाद क्या

play04:41

होगा यह वापस से रिक्वेस्ट जो रिस्पांस है

play04:44

वो हमारे क्लाइंट में आएगा एंड उसके बाद

play04:45

हमारे जितने भी कंपोनेंट्स हैं वो रिर

play04:47

करेंगे विद दी डाटा तो ये है सि ये है

play04:50

सिंपल अप्रोच जो अभी तक सिंपल रिएक्ट के

play04:53

अंदर हो रही थी ओके अब इसमें प्रॉब्लम्स

play04:56

को आइडेंटिफिकेशन में प्रॉब्लम्स को

play04:58

आइडेंटिफिकेशन ना स्टार्ट करते हैं तो

play05:00

सबसे पहली प्रॉब्लम जो है दैट इज कि यहां

play05:03

तक ना यहां तक सिर्फ जेएस का बंडल डाउनलोड

play05:06

हो रहा था एंड यहां तक यूजर वाज स्टेयरिंग

play05:09

एट अ ब्लैंक स्क्रीन तो यहां पे हम बोल

play05:10

देते हैं दैट यहां तक क्या था ब्लैंक

play05:12

स्क्रीन थी तो मतलब कि यूजर एक्सपीरियंस

play05:14

यहां पर बिल्कुल भी अच्छा नहीं है बिकॉज़

play05:16

यूजर तुम्हारी वेबसाइट पे आया एंड ही इज

play05:19

स्टेयरिंग एट अ ब्लैंक स्क्रीन राइट तो

play05:21

बहुत हाई चांसेस है दैट यूजर तुम्हारी

play05:23

वेबसाइट को छोड़ के जा सकता है प्लस यहां

play05:25

पर एक और प्रॉब्लम है ओवर टाइम जैसे-जैसे

play05:27

हम और फीचर्स ऐड करें हमारे एप्लीकेशन के

play05:30

अंदर हमारा जो ये जेएस बंडल साइज है ये

play05:33

ओवर टाइम इंक्रीज होता जाएगा जिससे हमारा

play05:35

जो ये टाइम है ना ब्लैंक स्क्रीन का ये

play05:37

इंक्रीज होता जाएगा ओके सो पहली प्रॉब्लम

play05:41

ये है दूसरा क्या होगा इस पर्टिकुलर पॉइंट

play05:43

पे राइट इस पर्टिकुलर पॉइंट पे यूजर विल

play05:45

गेट द फर्स्ट पेंट ओके फर्स्ट पेंट का

play05:48

क्या मतलब होता है दैट इस पर्टिकुलर पॉइंट

play05:51

ऑफ टाइम पे यूजर को कुछ स्क्रीन पर विजिबल

play05:54

होगा कुछ कंटेंट चाहे वो लोडिंग कंटेंट ही

play05:56

है लेकिन इस पर्टिकुलर पॉइंट पर क्या होगा

play05:58

हमारा जो पेज है वो फर्स्ट पेंट होगा जैसे

play06:01

फुटर दिखना स्टार्ट हो जाएगा हेडर दिखना

play06:02

स्टार्ट हो जाएगा बट स्टिल पेज के अंदर

play06:05

अभी कंटेंट नहीं है अभी हर जगह हमें

play06:07

लोडिंग इंडिकेटर्स दिख रहे हैं तो अभी भी

play06:08

यूजर को यहां पे वेट करना पड़ेगा ओके

play06:11

व्हिच इज ओके बट एटलीस्ट यूजर को कुछ दिख

play06:12

रहा है एंड यहां पर बिकॉज हमारी जो

play06:15

जावास्क्रिप्ट है वो लोड हो चुकी है तो

play06:17

हमारा पेज यहां पर इंटरेक्ट है ओके

play06:19

इंटरेक्ट का क्या मतलब है दैट अगर कोई

play06:21

बटंस वगैरह है हमारी स्क्रीन पे तो वो सब

play06:23

विजिबल है वो सब वर्किंग है बट ऑफकोर्स

play06:25

हमारे पास कोई भी कंटेंट नहीं है इस पॉइंट

play06:27

तक व्हिच इज ओके देन व्हाट हैपेंस जब

play06:30

हमारी ये डीबी क्वेरी होगी एंड उसके बाद

play06:32

जब ये री रेंडर होगा हेयर आई कैन से इस

play06:35

पर्टिकुलर पॉइंट ऑफ टाइम पे आई कैन से दैट

play06:37

आवर पेज इज रेडी आवर पेज इज रेडी विद दी

play06:40

कंटेंट एंड उसके बाद ही यूजर हमारी

play06:42

वेबसाइट के साथ इंटरेक्ट करना स्टार्ट कर

play06:44

सकता है बिकॉज़ कंटेंट हमारा इस पॉइंट तक

play06:47

रेडी हुआ तो अगर हम इस पर्टिकुलर

play06:49

आर्किटेक्चर को थोड़ा सा डीप एनालाइज करते

play06:51

हैं व्हाट यू विल नोटिस इज़ दैट फर्स्ट ऑफ

play06:53

ऑल यहां पर जो हमारा एसओ है ना वो बिल्कुल

play06:55

ही पुअर स्कोर में आएगा रीजन बीइंग फर्स्ट

play06:58

ऑफ ऑल हमारी जो वेब वेबसाइट है वो बहुत ही

play07:00

स्लो लोड हो रही है राइट तो यहां पर हमारी

play07:01

जो वेबसाइट है वो बहुत ज्यादा स्लो लोड हो

play07:04

रही है सेकंड यूजर को इनिशियली ब्लैंक

play07:07

स्क्रीन देखनी पड़ रही है जिससे हमारा जो

play07:09

यूजर ड्रॉप परसेंटेज है वो बहुत ज्यादा

play07:11

इंक्रीज हो सकता है तो ये थी नॉर्मल

play07:14

रिएक्ट तो नॉर्मल रिएक्ट के अंदर डेवलपर

play07:17

एक्सपीरियंस वाज टू गुड ठीक है तो जब इफ

play07:20

यू आर अ रिएक्ट डेवलपर तो अगर हम रिएक्ट

play07:22

के साथ यूज़ करके कोई एप्लीकेशंस बना रहे

play07:23

हैं तो एज अ डेवलपर मेरा जो एक्सपीरियंस

play07:26

है बिल्डिंग एप्लीकेशंस वो फास्ट होगा

play07:28

राइट बिकॉज़ मुझे डॉम को मैनुअली अपडेट या

play07:30

डॉम को मैनिपुलेट नहीं करना पड़ रहा तो

play07:32

रिएक्ट वाज अ गुड लाइब्रेरी फॉर डेवलपर्स

play07:34

बट इसके कॉन्स क्या थे दैट हमने यूजर

play07:36

एक्सपीरियंस को एंड हमने दैट इज नोन एज

play07:38

लाइक य एंड हमने एसओ को कॉम्प्रोमाइज कर

play07:41

दिया राइट तो यह थी नॉर्मल रिएक्ट व्हिच

play07:44

इज गुड नाउ नेक्स्ट यस टीम ने क्या किया

play07:47

नेक्स्ट यस टीम ने इसको एज एन अपॉर्चुनिटी

play07:49

लिया तो उन्होंने देखा दैट रिएक्ट एक बहुत

play07:51

ही पावरफुल लाइब्रेरी है नो डाउट इन दैट

play07:53

डेवलपर्स लव रिएक्ट लेकिन इसको हम थोड़ा

play07:56

सा ऑप्टिमाइज कर सकते हैं राइट तो

play07:57

उन्होंने क्या किया इस इसी आर्किटेक्चर को

play08:00

हम कर लेते हैं कॉपी एंड इसको हम वापस से

play08:01

यहीं पे कर लेते हैं पेस्ट तो यहां पर हम

play08:03

बात करेंगे अब नेक्स्ट यर्स की पुराने

play08:05

नेक्स्ट ईयर्स की जिसमें हमारे पास पेजेस

play08:07

राउटर होता था ओके तो यहां पर हम बात करते

play08:09

हैं नेक्स्ट यर्स जिसमें हम क्या यूज करते

play08:11

थे जिसमें हम यूज़ करते थे पेजेस राउटर

play08:13

यानी कि सर्वर साइड रेंडरिंग की सपोर्ट थी

play08:15

राइट तो नेक्स्ट य इस पूरे आर्किटेक्चर को

play08:18

किस तरह से

play08:19

रीफैक्स करते हैं लेट्स रिमूव ऑल द एरोज

play08:21

ठीक है सारे एरोज को रिमूव करते हैं

play08:23

उन्होंने बोला हम क्या करेंगे ना हम इस

play08:25

डीबी क्वेरी को ना पहले बैक एंड पे करेंगे

play08:27

बिकॉज हम सर्वर साइड रेंडरिंग कांसेप्ट

play08:30

लेकर आ रहे हैं तो वो कांसेप्ट लेकर आए थे

play08:31

सर्वर साइड रेंडरिंग का ओके तो सर्वर साइड

play08:34

रेंडरिंग में व्हाट यू कैन डू इज अब हम

play08:35

डीवी क्वेरी पहले कर सकते हैं बिकॉज हमारा

play08:38

जो कंपोनेंट है हमें पता है हमारा जो

play08:39

रिएक्ट है वो पहले सर्वर पर रेंडर होगा

play08:42

उसके बाद आल्सो व्हाट दे डिड इज जो ये

play08:44

रेंडर शेल है ना उसको भी इन्होंने शिफ्ट

play08:47

कर दिया सर्वर के ऊपर मतलब कि जो भी हम

play08:50

कोड रिएक्ट के अंदर लिखेंगे उसका जो

play08:52

फर्स्ट रेंडर होगा वो सर्वर के ऊपर होगा

play08:55

व्हिच इज गुड वो सर्वर के ऊपर होगा तो

play08:58

इससे क्या हुआ ठीक है इससे जो हमारा जेएस

play09:00

बंडल साइज है उसको हम थोड़ा सा यहां पे

play09:01

शिफ्ट करते हैं अब हमारा जो ये फर्स्ट

play09:04

पेंट था ना इफ यू रिमेंबर दिस फर्स्ट पेंट

play09:06

वाली चीज अब वो फर्स्ट पेंट हमारी यहां पर

play09:08

आ चुकी है राइट तो मतलब कि आई विल टेल यू

play09:11

व वन थिंग ब्लैंक स्क्रीन अब यहां से चली

play09:13

गई बिकॉज़ क्या हो रहा है हमारा जो रिएक्ट

play09:16

एप्लीकेशन है वो पहले सर्वर पर रडर हो रहा

play09:18

है एंड जो भी हमारा

play09:22

एटीएमएल पे सेंड कर देते हैं ओके तो यू

play09:25

कैन एज्यूम दैट हमारे पास इस पर्टिकुलर अप

play09:28

पॉइंट ऑफ टाइम पे हम हमारे पास फर्स्ट

play09:29

पेंट होगा बिकॉज़ हमारा जो डीबी क्वेरी है

play09:32

वो बैक एंड पे हुआ उसके बाद इस रेंडर शेल

play09:34

में हमारे पास कुछ डटा भी है जो इस डीबी

play09:36

क्वेरी ने रिटर्न किया होगा एंड हमारा जो

play09:38

फर्स्ट पेंट है वो काफी ज्यादा ऑप्टिमाइज

play09:40

हो चुका है एंड यू कैन सी दैट पहले हमारा

play09:42

फर्स्ट पेंट काफी लेट होता था लेकिन अब

play09:43

हमारा फर्स्ट पेंट पहले होता है व्हिच इज

play09:46

गुड द प्रॉब्लम इज दैट ठीक है हमारे पास

play09:49

यहां पर आया लेकिन अभी जो हमारा पेज है ना

play09:52

इस पर्टिकुलर पॉइंट ऑफ टाइम पे वो

play09:54

इंटरेक्ट नहीं कर सकता देखो यहां पर लेटर

play09:56

से हमारे पास एक कोई रिएक्ट का कोड था ठीक

play09:58

है हमारे पास यहां पर एक रिएक्ट का कोड था

play10:00

ये ये सर्वर पर रेंडर हो गया ये सर्वर पर

play10:02

रेंडर हो गया विद दी डाटा बिकॉज़ हमने

play10:04

सर्वर के ऊपर क्या किया हमने सर्वर के ऊपर

play10:06

डीवी क्वेरीज वगैरह भी की तो यानी कि इस

play10:07

पर्टिकुलर पॉइंट ऑफ टाइम पे बट द प्रॉब्लम

play10:11

इज दैट ये पर्टिकुलर जो पेज है ना ये

play10:13

इंटरेक्टेबल नहीं है मतलब कि अगर इसके ऊपर

play10:15

कोई बटंस हैं इसके ऊपर कोई लिंक्स है

play10:17

एनीमेशंस है वो वर्क नहीं करेंगी एंड डू

play10:20

यू नो द रीजन उसका रीजन क्या है दैट इसको

play10:23

इंटरेक्टेबल होने के लिए जावास्क्रिप्ट की

play10:25

जरूरत है व्हिच इज गुड ओके तो इसको

play10:27

जावास्क्रिप्ट की जरूरत है तो यानी कि इस

play10:29

पॉइंट ऑफ टाइम पर क्या होगा हमारा जो

play10:31

ब्राउजर है ना वो जावास्क्रिप्ट को

play10:33

डाउनलोड करना स्टार्ट कर देगा ओके वो

play10:35

जावास्क्रिप्ट को डाउनलोड करना स्टार्ट कर

play10:37

देगा तो मतलब कि जब बैकग्राउंड में हमारी

play10:40

जावास्क्रिप्ट लोड हो रही है ना यूजर के

play10:42

पास एक कंटेंट है स्क्रीन के ऊपर वो भी

play10:44

विद डाटा व्हिच इज अ गुड थिंग उसके बाद

play10:47

क्या होगा अब हमारी जावास्क्रिप्ट लोड

play10:49

होगी 50mb की व्हिच इज ओके यूजर वेट कर

play10:51

रहा है तो बैकग्राउंड में हो रहा है एंड

play10:53

उसके बाद एक प्रोसेस होता है जिसको हम

play10:55

बोलते हैं हाइड्रेशन ओके जिसको हम बोलते

play10:57

हैं हाइड्रेशन रिएक्ट हाइड्रेशन उसके बाद

play10:59

क्या होगा ये रिएक्ट हाइड्रेशन होगा नाउ

play11:01

व्हाट इज दिस रिएक्ट हाइड्रेशन हाइड्रेशन

play11:03

का मतलब होता है दैट जितना भी हमारा पेज

play11:06

है राइट जितना भी हमारा स्टैटिक पेज था ना

play11:08

इसकी जब जेएस डाउनलोड हो जाती है उसके बाद

play11:11

रिएक्ट क्या करती है इस पूरे डॉम को पूरे

play11:14

हमारे पेज को ट्रैवर्स करती है डॉम

play11:16

ट्रैवर्स करती है एंड उसके ऊपर जितने भी

play11:18

इवेंट लिसन होते हैं वो अटैच कर देती है

play11:21

सो दैट हमारा जो पेज है वो इंटरेक्टेबल हो

play11:23

जाए तो मतलब कि क्या हुआ दैट इस पर्टिकुलर

play11:26

पॉइंट ऑफ टाइम पे हमारे पास सिर्फ फर्स्ट

play11:27

पेंट था लेकिन हमारा पेज जो था वो

play11:30

इंटरेक्टेबल नहीं था बटंस वगैरह वर्क नहीं

play11:32

करेंगे क्यों बिकॉज़ अभी जावास्क्रिप्ट

play11:34

डाउनलोड नहीं हुई ठीक है उसके बाद

play11:36

जावास्क्रिप्ट डाउनलोड होगी एंड फिर

play11:38

रिएक्ट हाइड्रेशन प्रोसेस करेगी इसका क्या

play11:40

मतलब दैट जितने भी हमारे कंपोनेंट्स हैं

play11:43

जिनको इंटरेक्टेबल इंटरेक्ट बिलिटी चाहिए

play11:45

जैसे बटंस को कोई इवेंट लिस्नर्स चाहिए या

play11:48

फिर कोई एनीमेशंस है तो वो सारी चीजें

play11:50

रिएक्ट यहां पर करेगी एंड इस पर्टिकुलर

play11:52

पॉइंट ऑफ टाइम पे क्या होगा हमारा जो पेज

play11:54

है वो इंटरेक्ट हो जाएगा ओके इसके बाद

play11:57

हमारा इंटरेक्ट हो गया एंड उसके बाद इफ यू

play12:00

हैव एनीथिंग ठीक है इसके बाद अगर हमारे

play12:02

पास कोई भी ऐसी चीज है जिसमें हमें

play12:03

क्लाइंट साइ डेटा फेचिंग करनी है उसके बाद

play12:06

वी कैन मेक अ न्यू डीबी क्वेरी ठीक है

play12:08

लाइक फॉर एग्जांपल इफ यू वांट ठीक है अगर

play12:10

कोई भी हमें करना है तो वो प्रोसेस एज इट

play12:12

इज फिर कंटिन्यू रहता है क्लाइंट

play12:13

कंपोनेंट्स के अंदर ठीक है तो यानी कि अगर

play12:16

हमारे पास कोई भी यूज़ इफेक्ट्स है या फिर

play12:17

हम रिएक्ट क्वेरी यूज़ कर रहे हैं तो फिर

play12:19

वो चीजें एज नॉर्मल चलती हैं बट द थिंग इज

play12:21

दैट एक सेकंड हम इसको पहले एरोज बना लेते

play12:23

हैं राइट तो ये चीजें नॉर्मल चलती हैं तो

play12:25

बेसिकली यहां पर हुआ क्या हमने फर्स्ट

play12:27

पेंट को बहुत ज्यादा ऑप्टिमाइज कर दिया

play12:29

राइट फर्स्ट पेंट भी प्लस यहां पर हमारे

play12:32

पास पार्शियल डाटा भी होगा ओके तो जितना

play12:35

भी डाटा हमने सर्वर साइड रेंडर किया है ना

play12:37

वो हमारे पास यहां पर होगा ओके तो इससे

play12:40

क्या चीजें सॉल्व हुई नंबर वन चीज जो

play12:42

सॉल्व हुई दैट इज एसओ बिकॉज अब एसईओ के

play12:45

पास कोई भी ब्लैंक स्क्रीन नहीं है राइट

play12:47

इस पर्टिकुलर टाइम पे हमारे पास एक ब्लैंक

play12:49

स्क्रीन थी तो जितने भी बॉट्स आएंगे उनको

play12:51

पहली बात क्या दिखेगा उनको ब्लैंक स्क्रीन

play12:53

दिखेगी एंड बिकॉज हमारा सारा कंटेंट

play12:56

जावास्क्रिप्ट के थ्रू जनरेट हो रहा था तो

play12:58

उस केस में में क्या होगा एसओ का जो स्कोर

play13:00

है वो बहुत ज्यादा पुअर हो जाएगा बट यहां

play13:02

पर हम क्या करते हैं हम रेंडरिंग करते हैं

play13:04

सर्वर पे एंड जो भी हमारा

play13:09

html4 पे सेंड कर देते हैं तो इसका क्या

play13:11

मतलब दैट जो हमारे पास पार्शियल डाटा है

play13:14

ना वो पहली बात हमारे पास फर्स्ट पेंट है

play13:16

तो यानी कि कोई भी ब्लैंक स्क्रीन नहीं है

play13:18

एंड बिकॉज़ जितना भी डाटा हमने सर्वर पे

play13:20

रेंडर किया है उसके हमारे पास स्टैटिक

play13:28

कोई भी ब्लैंक स्क्रीन नहीं दिखनी पड़ेगी

play13:31

राइट एंड थर्ड बेस्ट थिंग इज दैट अगर एज अ

play13:34

डेवलपर आई एम कंफर्टेबल विद रिएक्ट तो मैं

play13:35

यहां पर रिएक्ट में ही कोड कर सकता हूं तो

play13:37

मुझे कोई भी न्यू चीज सीखने की जरूरत नहीं

play13:39

है मुझे कोई भी मतलब अपने स्किल्स के साथ

play13:41

या फिर अपने अ कंफर्ट के साथ कंप्रोमाइज

play13:44

नहीं करना पड़ेगा आई कैन कंटिन्यू माय

play13:46

नॉलेज ऑफ रिएक्ट यूजिंग इन द नेक्स्ट

play13:48

ईयर्स तो यह था हमारा पेजेस राउटर ओके

play13:51

पेजेस राउटर नाउ डू यू सी एनी प्रॉब्लम

play13:54

हियर आल्सो तो यहां पर अगर हम देखें दैट

play13:57

नेक्स्ट यर्स ने बहुत ही अच्छे तरीके से

play13:59

प्रॉब्लम को सॉल्व किया राइट बट यहां पर

play14:01

एक प्रॉब्लम था तो आई विल टेल यू द

play14:02

प्रॉब्लम ओके इसको इसको बहुत आराम से

play14:04

समझना लेट अस से दैट ये जो हमारा पेज बना

play14:07

राइट सो लेट अस से दैट ये जो हमारा पेज

play14:09

आया इस पेज के अंदर ना यू हैव टोटल 200

play14:12

कंपोनेंट्स ओके यू हैव टोटल 200

play14:14

कंपोनेंट्स

play14:16

कंपोनेंट्स एंड अज्यू करते हैं दैट एक

play14:19

कंपोनेंट इज़ ऑफ़ 1 एब सो आई कैन से दैट 1

play14:21

एब ईच तो यानी कि हमारा टोटल

play14:23

जावास्क्रिप्ट का साइज क्या हुआ 200mb

play14:25

व्हिच इज़ ओके तो यानी कि इस पर्टिकुलर

play14:27

पॉइंट ऑफ़ टाइम पे हम 200 एब जेएस बंडल

play14:30

डाउनलोड कर रहे हैं ओके अगर मैं यहां पर

play14:33

बोलूं दैट इसमें से ना 150 कंपोनेंट्स ऐसे

play14:36

हैं जो लाइक सिंपल डाटा को डिस्प्ले करते

play14:39

हैं मतलब कि उसके अंदर कोई भी इंटरेक्ट

play14:41

बिलिटी है ही नहीं लेकिन 50 कंपोनेंट्स

play14:43

ऐसे हैं 50 कंपोनेंट्स ऐसे हैं जिसके अंदर

play14:46

यू हैव इंटरेक्टेबल व्हिच आर इंटरेक्टेबल

play14:49

ओके तो इंटरेक्टेबल जैसे फॉर एग्जांपल कोई

play14:51

बटन हो सकता है कोई लिंक हो सकता है तो इस

play14:52

तरह के कुछ कंपोनेंट्स है सो माय पॉइंट इज

play14:55

दैट क्या हमें इस पर्टिकुलर कंपोनेंट्स की

play14:58

दैट इज 50mb क्या हमें इसकी जावास्क्रिप्ट

play15:00

डाउनलोड करने की जरूरत है बिकॉज़ अगर मैं

play15:03

यहां पे वापस जाता हूं फॉर एग्जांपल अगर

play15:04

मैं अपनी वेबसाइट की एग्जांपल लेता हूं

play15:06

यहां पर आई कैन सी दैट ये जो सब्सक्राइबर

play15:08

काउंट है ये जो वीडियोस है ये इंटरेक्टेबल

play15:10

नहीं है राइट ये सिर्फ एक डिस्प्ले है

play15:12

क्या मुझे इस पर्टिकुलर कंपोनेंट की या

play15:14

फिर या फिर फॉर एग्जांपल अगर हम इस

play15:16

कंपोनेंट की बात करते हैं जिसमें सिर्फ

play15:18

टेक्स्ट डाटा है क्या मुझे इसकी

play15:19

जावास्क्रिप्ट डाउनलोड करने की जरूरत है

play15:21

अगर मैं नीचे भी जाता हूं यू कैन सी दैट

play15:23

ये सिंपल इमेजेस है राइट तो क्या मुझे

play15:25

इनकी जावास्क्रिप्ट डाउनलोड करने की जरूरत

play15:27

है नहीं बिकॉज उसमें कोई इंटरेक्ट बिलिटी

play15:30

नहीं है तो हम क्या करते हैं तो नेक्स्ट

play15:32

आइट में हम क्या करेंगे हम कहीं ना कहीं

play15:35

इस पर्टिकुलर जावास्क्रिप्ट को एलिमिनेट

play15:37

करने का ट्राई करेंगे सो दैट ये जो हमारा

play15:40

जीएस का बंडल साइज है इसको हम रिड्यूस कर

play15:42

पाएं ओके बिकॉज़ इस टाइम पे क्या हो रहा

play15:44

है जो कंपोनेंट्स इंटरेक्टेबल भी नहीं है

play15:47

हम उसकी भी जेएस को डाउनलोड कर रहे हैं तो

play15:49

इससे क्या हो रहा है मेरा हाइड्रेशन

play15:50

प्रोसेस लेट हो रहा है एंड उससे और क्या

play15:52

हो रहा है एक तो मेरा जेएस का बंडल साइज

play15:54

इंक्रीज हो रहा है हाइड्रेशन प्रोसेस लेट

play15:55

हो रहा है एंड मेरा जो पेज है जो उसका

play15:58

फर्स्ट इंटरेक्टेबल पॉइंट है वो लेट हो

play16:00

जाता है ठीक है तो हाउ टू डू दिस इज ठीक

play16:03

है तो हाउ टू डू दिस इज तो इस केस में

play16:05

व्हाट यू कैन डू इज इस केस में वी हैव

play16:07

सर्वर कंपोनेंट्स ठीक है इस पर्टिकुलर

play16:08

प्रॉब्लम को सॉल्व करने के लिए वी हैव

play16:10

सर्वर कंपोनेंट्स तो रिएक्ट

play16:13

18.4 रिएक्ट 13.4 ऑनवर्ड व्हाट हैपेंड नॉट

play16:16

रिएक्ट सॉरी नेक्स्ट ए 13.4 तो यहां पे हम

play16:18

लिखते हैं नेक्स्ट एस 13.4 ऑनवर्ड एक न्यू

play16:21

कांसेप्ट आया था दैट वाज इन प डायरेक्टरी

play16:24

जिसके अंदर वी हैड एन ऑप्शन फॉर सर्वर

play16:26

कंपोनेंट्स ओके तो तो सर्वर कंपोनेंट्स

play16:29

कांसेप्ट बड़ा सिंपल है वो क्या कहते हैं

play16:30

दैट व्हेन एवर यू आर मेकिंग अ कंपोनेंट ना

play16:33

आप ना एक्सप्लीसिटली मेंशन करो दैट ये ना

play16:35

सर्वर कंपोनेंट है ठीक है वी हैव टू मेंशन

play16:37

दैट ये सर्वर कंपोनेंट है एंड वी हैव टू

play16:39

टेल दैट ये क्या है क्लाइंट कंपोनेंट तो

play16:41

व्हाट रिएक्ट विल डू इज अगर कोई सर्वर

play16:44

कंपोनेंट है ना अगर कोई सर्वर कंपोनेंट है

play16:47

तो उसकी रेंडरिंग बैक एंड पे ही होगी एंड

play16:50

उसका जो जेएस है ना उसकी जो जावास्क्रिप्ट

play16:53

है वो फ्रंट एंड के ऊपर कभी भी शिप नहीं

play16:55

होगी दोबारा बताता हूं इस इस पॉइंट पे

play16:58

रिएक्ट क्या कहती है दैट एक काम करो यू

play17:00

हैव टू टेल मी दैट कौन सा कंपोनेंट सर्वर

play17:03

कंपोनेंट है कौन सा कंपोनेंट क्लाइंट

play17:04

कंपोनेंट है एंड बेस्ड ऑन दैट व्हाट आई

play17:07

विल डू इज कि अगर वो सर्वर कंपोनेंट है ना

play17:09

तो उसकी जो जावास्क्रिप्ट है ना वो फ्रंट

play17:11

एंड पे हम शिप ही नहीं करेंगे डू यू नो

play17:13

व्हाई बिकॉज उसको हम बैक एंड पे ही रेंडर

play17:15

कर लेंगे हम सर्वर पर ही उसको रेंडर कर

play17:17

लेंगे एंड उसका जो भी डाटा बनेगा जो भी

play17:19

उसका एटीएमएल सीएसएस बनेगा उसको हम फ्रंट

play17:22

एंड पे कर देंगे स्ट्रीम तो जिससे क्या

play17:23

होगा जिससे हमारा जेएस का बंडल साइज हो

play17:26

जाएगा डिक्रीज तो इस पर्टिकुलर पॉइंट पे

play17:29

हमारे पास सर्वर कंपोनेंट्स 150 थे अगर

play17:30

क्लाइंट कंपोनेंट सिर्फ 50 हैं तो यानी कि

play17:32

50mb ऑफ़ जावास्क्रिप्ट ही होगी यहां पे

play17:35

तो यहां पर वी हैव रिड्यूस दिस बंडल साइज़

play17:37

जिससे क्या हुआ ये जो पर्टिकुलर बंडल

play17:39

साइज़ था ये हमारा हो गया बहुत ज्यादा

play17:40

डिक्रीज ओके तो ये हमारा डिक्रीज हो गया

play17:43

एंड ऑफकोर्स इससे क्या होगा हमारा

play17:45

हाइड्रेशन प्रोसेस भी थोड़ा सा फास्ट होगा

play17:47

बिकॉज़ स्मॉलर जावास्क्रिप्ट एंड बहुत

play17:49

जल्दी होगा राइट तो हमारा हाइड्रेशन

play17:51

प्रोसेस भी हो गया छोटा जिससे हमारा जो

play17:53

पेज का इंटरेक्टेबल टाइम था ओके टाइम टू

play17:57

इंटरेक्ट वो भी हो गया डिक्रीज एंड ओवरऑल

play17:59

मेरे वेबसाइट की जो स्पीड है यू कैन

play18:01

एज्यूम दैट बहुत ज्यादा इंक्रीज हो जाएगी

play18:03

बिकॉज हमने अननेसेसरीली जावास्क्रिप्ट को

play18:05

रिमूव कर दिया तो यह कंसेप्ट है सर्वर

play18:08

कंपोनेंट्स का ओके तो सर्वर कंपोनेंट्स तो

play18:10

अगर हम एक बेसिक डिफरेंस देखते हैं ना

play18:12

सर्वर साइड रेंडरिंग में तो सर्वर साइड

play18:14

रेंडरिंग्स का मतलब होता है बोथ ओके बोथ

play18:17

ऑन क्लाइंट एंड सर्वर बट जब हम सर्वर

play18:21

कंपोनेंट्स की बात करते हैं ना सर्वर

play18:22

कंपोनेंट्स की तो इसका मतलब होता है सर्वर

play18:26

ओनली तो यानी कि हम उसको एकस इलिसिटली बता

play18:29

रहे हैं दैट यार ये ना एक सर्वर कंपोनेंट

play18:31

है इसकी जावास्क्रिप्ट को डाउनलोड मत करना

play18:33

ओके एंड अगर वो एक सर्वर कंपोनेंट है ना

play18:36

यू कैन नॉट ऐड इंटरेक्टेबल ठीक है तो

play18:40

उसमें इंटरेक्टेबल हम ऐड कर ही नहीं सकते

play18:42

तो इसको एक बार प्रैक्टिकली देखते हैं तो

play18:44

आई होप दैट हमें आर्किटेक्चर तो समझ आ गया

play18:46

तो एक बार मैं रीकैप भी कर देता हूं तो

play18:48

नॉर्मल रिएक्ट के अंदर क्या होता था दैट

play18:49

यू हैव जेएस बंडल तो पहले जेएस बंडल

play18:51

डाउनलोड होता था व्हिच इज लाइक वेरी ह्यूज

play18:53

उसके बाद हमारा रेंडर होता था जिसमें

play18:55

हमारे पास लोडिंग स्टेट्स आती थी एंड इस

play18:57

पर्टिकुलर पॉइंट ऑफ़ टाइम पे यूजर के पास

play18:58

बस एक ब्लैंक स्क्रीन है फिर हमारा पेज

play19:00

इंटरेक्ट भी हो जाता था एंड फर्स्ट पेंट

play19:03

भी होता था फिर जितने भी हमारे यूज इफेक्ट

play19:05

हुक्स होते हैं क्लाइंट पे वो डेटाबेस

play19:06

क्वेरीज करेंगे मतलब कि वो सर्वर के ऊपर

play19:08

एपीआई कॉल्स करेंगे एंड उसके बाद जब हमारे

play19:11

पास डेटा वापस आएगा उसके बाद री रेंडर एंड

play19:13

इस पर्टिकुलर पॉइंट ऑफ टाइम पे हमारा जो

play19:14

कंटेंट है वो रेडी होगा नेक्स्ट इस ने

play19:17

उसको सॉल्व किया यूजिंग सर्वर साइड

play19:18

रेंडरिंग जिसमें हम क्या कर सकते हैं हम

play19:19

डेटाबेस क्वेरी को पहले कर सकते हैं प्लस

play19:22

हम रेंडर शेल को भी हम थोड़ा सा पहले कर

play19:24

सकते हैं मतलब कि हम पेजेस को रिएक्ट को

play19:26

सर्वर के ऊपर रेंडर कर सकते हैं एंड उसके

play19:29

बाद हम क्या कर सकते हैं

play19:30

html4 पे सेंड कर देंगे उससे क्या होगा

play19:34

हमारे पास कुछ डाटा पहले ही होगा एंड

play19:36

हमारा जो फर्स्ट पेंट है वो थोड़ा सा

play19:37

जल्दी हो जाएगा सो यू कैन सी दैट फर्स्ट

play19:39

पेंट को हमने इधर मूव कर दिया व्हिच इज

play19:41

ग्रेट लेकिन इस पर्टिकुलर पॉइंट ऑफ टाइम

play19:44

पे जो हमारा पेज है वो इंटरेक्टेबल नहीं

play19:46

होगा बिकॉज़ हमारे पास अभी जावास्क्रिप्ट

play19:48

नहीं है तो जावास्क्रिप्ट लोड होगी फिर एक

play19:50

प्रोसेस होता है हाइड्रेशन का जिसके अंदर

play19:52

रिएक्ट पूरे डॉम को ट्रैवर्स करके पेज को

play19:55

इंटरेक्टेबल बनाती है बिकॉज़ अब हमारे पास

play19:57

जावास्क्रिप्ट डाउ ड हो चुकी है एंड उसके

play19:59

बाद हमारा पेज यहां पर इंटरेक्ट हो जाएगा

play20:01

तो ये पहले वाली अप्रोच से अच्छा है पहले

play20:03

वाली अप्रोच से फास्ट है थर्ड आइट केशन

play20:06

में व्हाट वी हैव डन इज़ हमने ट्राई किया

play20:07

कि अगर हम किसी तरह से इस जेएस बंडल को

play20:10

डिक्रीज कर सकें इस जेएस बंडल को हम कैसे

play20:12

डिक्रीज कर रहे हैं हम एक्सप्लीसिटली

play20:14

मेंशन करेंगे दैट कौन सा हमारा सर्वर

play20:16

कंपोनेंट है कौन सा हमारा क्लाइंट

play20:17

कंपोनेंट है एंड सर्वर कंपोनेंट्स की जो

play20:20

जेएस है उसको हम फ्रंट एंड पे शिफ्ट नहीं

play20:21

करेंगे जिससे मेरा जेएस बंडल साइज बहुत

play20:23

ज्यादा हो जाएगा छोटा जिससे हाइड्रेशन

play20:25

प्रोसेस भी मेरा बहुत जल्दी होगा एंड मेरा

play20:27

पेज जल्दी लोड एंड इंटरेक्टेबल हो जाएगा

play20:30

इंप्रूविंग ओवरऑल य यूज एक्सपीरियंस एंड द

play20:33

एसओ तो ये है पूरा सर्वर कंपोनेंट्स का

play20:36

कंसेप्ट अब इसको हम थोड़ा सा प्रैक्टिकली

play20:38

देखते हैं ओके तो अगर मैं यहां पर एक कोड

play20:40

को ओपन करता हूं तो यहां पर हम एक कोड को

play20:42

ओपन कर लेते हैं तो ये है मेरा वीएस कोड

play20:45

जिसके अंदर एक नॉर्मल एक प्लेन अ नेक्सस

play20:48

एप्लीकेशन है विद प राउटर तो यहां पर हम

play20:51

एक काम करते हैं यहां पर लेट्स डू अ यान

play20:52

डेव ओके तो पहले हम इसको यार्न डेव कर

play20:54

लेते हैं तो ऑन द डेवलपमेंट सर्वर तो यहां

play20:57

पर व्हाट यू विल नोटिस इ दैट जो भी हम पप

play20:59

राउटर के अंदर बनाते हैं कंपोनेंट्स वो

play21:01

बाय डिफॉल्ट सर्वर कंपोनेंट्स होते हैं

play21:03

ओके वो बाय डिफॉल्ट क्या होता है सर्वर

play21:05

कंपोनेंट्स फॉर एग्जांपल एक रूट बनाते हैं

play21:07

यूजर का इसके अंदर लेट्स डू वन थिंग इसके

play21:09

अंदर हम एक पेज टीए एक बनाते हैं ओके पेज

play21:12

डॉट t ए एक ओके एंड यहां पर व्हाट आई कैन

play21:15

डू आई कैन से एक्सपोर्ट डिफॉल्ट

play21:17

डिफॉल्ट फंक्शन एंड इसको हम बोलते हैं

play21:20

यूजर पेज एंड इसके अंदर हम रिटर्न करेंगे

play21:23

एक डेव डेव के अंदर वी कैन से दैट h1 दैट

play21:26

दिस इज ए यूजर पेज तो ये क्या है ये बाय

play21:29

डिफॉल्ट क्या है ये एक सर्वर कंपोनेंट है

play21:31

राइट बिकॉज़ प पप डायरेक्टरी के अंदर है प

play21:33

राउटर के अंदर है पप राउटर के अंदर सभी

play21:36

कंपोनेंट्स बाय डिफॉल्ट क्या होते हैं

play21:37

सर्वर कंपोनेंट्स तो मतलब कि अगर मैं यहां

play21:40

पर स्ल यूजर के ऊपर हिट करूंगा ओके एंड

play21:42

इसको हम थोड़ा सा ज़ूम आउट कर लेते हैं अ

play21:44

स्ल यूजर नॉट यूजर्स तो जैसे मैं इसको

play21:47

स्लैश यूजर के ऊपर हिट करूंगा व्हाट यू

play21:49

विल नोटिस इज अगर मैं अपनी सोर्सेस टैब

play21:51

में जाता हूं एंड मैं यहां पर वेब पैक के

play21:53

ऊपर क्लिक करता हूं तो व्हाट ड यू नोटिस

play21:55

इज दैट यहां पर हमारे पास कोई भी कोड नहीं

play21:57

है राइट यहां पर हमारे पास कोई भी कोड

play21:59

नहीं है एंड ये पर्टिकुलर जो पेज है ये

play22:01

पर्टिकुलर जो कंपोनेंट है वो सर्वर साइड

play22:03

ेंड है ठीक है थोड़ा सा इसको और आगे

play22:06

प्रोसीड करते हैं ठीक है सो व्हाट आई विल

play22:07

डू इज अ जस्ट अ सेकंड या सो व्हाट आई विल

play22:10

डू इज़ अगर मैं यहां पर एक बटन ऐड करने का

play22:12

ट्राई करता हूं व्हिच इज लाइक क्लिक मी

play22:14

एंड इसके ऊपर आई कैन से ऑन क्लिक एंड आई

play22:18

कैन से कसोल डलॉग हे देयर व्हाट यू विल

play22:22

नोटिस दैट हमारे पास एक एरर आएगा ठीक है

play22:24

तो ये एरर क्या है ये एरर बोलता है दैट इफ

play22:26

यू नीड इंटरएक्टिविटी कंसीडर कन्वर्ट

play22:28

पार्ट ऑफ दिस एज अ क्लाइंट कंपोनेंट तो

play22:30

मतलब कि इवेंट हैंडलर्स हम अटैच नहीं कर

play22:32

सकते सर्वर कंपोनेंट्स के ऊपर ठीक है तो

play22:35

इसका क्या सॉल्यूशन हम क्या कर सकते हैं

play22:37

हम सिर्फ इस पर्टिकुलर बटन को एक क्लाइंट

play22:39

कंपोनेंट बनाएंगे ठीक है तो उसके लिए आई

play22:41

कैन से दैट एक कंपोनेंट बना लेते हैं बटन

play22:44

ड ts6 एंड यहां पर आई कैन से एक्सपोर्ट अ

play22:47

डिफॉल्ट ओके एक्सपोर्ट डिफॉल्ट एंड इसको

play22:50

हम बोलेंगे फंक्शन एंड इसको हम एक बटन बना

play22:53

लेते हैं सो बटन तो यह हमारा एक फंक्शनल

play22:56

कंपोनेंट है जिसके अंदर हम एक सिम सल बटन

play22:58

को रिटर्न कर रहे हैं इसके ऊपर वी कैन से

play23:00

लाइक क्लिक मी ओके क्लिक मी एंड यहां पर

play23:03

हम क्या कर सकते हैं यहां पर हम बोल सकते

play23:05

हैं ऑन क्लिक तो हम क्या करना चाहते हैं

play23:07

हम यहां पर कुछ कंसोल डट लॉक करना चाहते

play23:09

हैं तो कंसोल डलॉग हे देयर ओके सो हे देयर

play23:14

एंड

play23:26

दैट्ची बटन यूज़ कर लेता हूं नाउ इफ आई गो

play23:29

बैक यू विल सी एरर इज गॉन ठीक है एरर चला

play23:31

गया एंड कंसोल के अंदर अगर मैं क्लिक मी

play23:33

पे क्लिक करता हूं तो व्हाट डू यू नोटिस

play23:35

दैट मेरा बटन सही से काम कर रहा है अब

play23:37

यहां पर एक इंटरेस्टिंग चीज को देखते हैं

play23:39

सोर्सेस टैब डू अ रिफ्रेश तो यहां पर अगर

play23:41

मैं जाता हूं वेब पैक इंटरनल प / यूजर

play23:46

क्या हमें यहां पर बटन . ts6 फाइल दिख रही

play23:48

है एंड उसकी जितनी भी जावास्क्रिप्ट है इस

play23:51

पर्टिकुलर चीज की वो भी हमें यहां पर

play23:53

दिखाई दे रही है तो यानी कि क्या हुआ जो

play23:55

ये पेरेंट कंपोनेंट है ना जो ये एक सर्वर

play23:57

कंपोट नेंट है इसकी जावास्क्रिप्ट हमें

play23:59

नहीं दिखाई दे रही यहां पर राइट यू कैन सी

play24:01

दैट इसकी जावास्क्रिप्ट नहीं है लेकिन

play24:03

बिकॉज़ ये बटन एक क्लाइंट कंपोनेंट है

play24:06

इसकी जावास्क्रिप्ट हमारे पास फ्रंट एंड

play24:08

पे आ रही है एंड यू विल सी दैट इसके अंदर

play24:10

सारे वो इवेंट लिसन हैं राइट सो दिस इज

play24:12

व्हाट इज हैपनिंग एक और चीज करके हम ट्राई

play24:15

कर सकते हैं तो यहां पर हम एक और कंपोनेंट

play24:17

बना लेते हैं इसको हम बोल देते हैं बटन

play24:19

सर्वर तो ये एक सर्वर बटन है ठीक है तो

play24:21

लाइक यू कैन अजूम दैट कुछ भी एक सर्वर

play24:23

कंपोनेंट है तो इसी पर्टिकुलर चीज को हम

play24:25

यहां पे कॉपी कर लेते हैं यूज़ क्लाइंट को

play24:27

हटा देते हैं एंड ऑन क्लिक को भी हटा देते

play24:28

हैं बिकॉज ये एक सर्वर कंपोनेंट है एंड

play24:30

इसको मैं बोलूंगा क्लिक मी सर्वर ओके एंड

play24:33

फिर हम क्या कर सकते हैं यहां पर हम एक

play24:35

काम करते हैं यहां पर हम एक बर टैग का यूज

play24:37

कर लेते हैं फिर हम यहां पर करेंगे दोबारा

play24:38

से बटन ठीक है दोबारा से हम यहां पर बोल

play24:41

सकते हैं सर्वर बटन सो पहले इंपोर्ट कर

play24:44

लेते हैं तो आई विल से इंपोर्ट ए बटन मतलब

play24:46

सर्वर बटन फ्रॉम डॉट

play24:48

स्ल बटन सर्वर तो इस ए बटन को भी हम यहां

play24:52

पे करेंगे रेंडर तो नाउ व्हाट यू विल

play24:54

नोटिस दैट हमारे पास एक क्लिक मी ऑन द

play24:56

सर्वर है क्लिक मी है राइट एंड अगर हम

play24:58

अपने जेएस बंडल को देखते हैं तो व्हाट यू

play25:00

विल नोटिस दैट हमारे पास सिर्फ और सिर्फ

play25:02

हमारे पास सिर्फ और सिर्फ कौन सी फाइल आ

play25:04

रही है यहां पर पप यूजर के अंदर सिर्फ बटन

play25:06

. t आ रही है बिकॉज़ वो एक क्लाइंट

play25:08

कंपोनेंट है ओके अगर मैं सर्वर बटन को भी

play25:11

यूज क्लाइंट करता हूं तो यू विल नोटिस दैट

play25:13

इसकी पर्टिकुलर जेएस भी हमारे पास फ्रंट

play25:15

एंड पे शिफ्ट होनी स्टार्ट हो जाएगी सो

play25:16

नाउ यू कैन सी दैट इसकी जो जेएस है वो भी

play25:19

हमारे पास फ्रंट एंड के ऊपर शिफ्ट हो रही

play25:21

है ओके तो इससे हम क्या कर सकते हैं हम

play25:23

बहुत कॉशस किस कंपोनेंट को सर्वर के ऊपर

play25:26

रखना है किस कंपोनेंट के ऊपर क्लाइंट के

play25:28

ऊपर रखना है उससे हम अपने जेएस बंडल को

play25:30

बहुत ज्यादा ऑप्टिमाइज कर सकते हैं तो ये

play25:33

पूरा कांसेप्ट है सर्वर कंपोनेंट्स का तो

play25:35

सर्वर कंपोनेंट्स का मतलब होता है सर्वर

play25:37

ओनली तो जब हम तो यहां पर एक एक एग्जांपल

play25:40

देता हूं फॉर एग्जांपल लेट अस से दैट वी

play25:42

आर मेकिंग सम अ ई-कॉमर्स ठीक है तो

play25:44

ई-कॉमर्स में इफ यू नोटिस दैट हमारे पास

play25:46

एक प्रोडक्ट कार्ड होता है राइट तो लेट अस

play25:48

से दैट यहां पर हमारे पास कोई इमेज है ठीक

play25:50

है यहां पर हमारे पास कोई इमेज है उसके

play25:52

बाद यहां पर हमारे पास प्राइसिंग मेंशन है

play25:55

अगर यह कार्ड है तो यहां पर हो सकता है

play25:56

लाइक आई एंड आ r लेट अस से आ आ 999 ओके

play26:00

एंड उसके बाद हमारे पास यहां पर एक बटन है

play26:02

राइट यहां पर हमारे पास एक बटन है जिसके

play26:04

ऊपर लिखा हुआ हो सकता है मे बी बाय नाउ तो

play26:06

यहां पर इफ यू हैव द कंपोनेंट वन सॉल्यूशन

play26:09

इज दैट हम क्या कर सकते हैं हम इस पूरे

play26:11

कंपोनेंट को यूज़ क्लाइंट कर सकते हैं हम

play26:13

इस पूरे कंपोनेंट को यूज़ क्लाइंट कर सकते

play26:15

हैं जिससे क्या होगा मेरा ये पूरा का पूरा

play26:17

कार्ड एक क्लाइंट कंपोनेंट बन जाएगा राइट

play26:19

दिस इज वन वे तो हो सकता है इसके जो

play26:21

जावास्क्रिप्ट बनेगी मे बी दैट इज ऑफ 1mb

play26:24

लेकिन मैं एक और चीज भी क्या कर सकता हूं

play26:26

मैं एक और चीज कर सकता हूं मैं सिर्फ इस

play26:27

बटन को यूज़ क्लाइंट कर सकता हूं मैं

play26:30

सिर्फ इस पूरे पूरे कंपोनेंट को क्लाइंट

play26:32

नहीं सिर्फ इस पर्टिकुलर बटन को क्लाइंट

play26:34

कर सकते हैं इसको सर्वर कर सकते हैं

play26:36

बिकॉज़ ये पर्टिकुलर चीज के अंदर कोई भी

play26:38

इंटरेक्टेबल नहीं है ये तो सिर्फ डेटा को

play26:40

डिस्प्ले कर र है जो एक्चुअल एक्शन है वो

play26:42

तो ये बटन कर रहा है ना तो इस पर्टिकुलर

play26:44

बटन को सिर्फ क्लाइंट करो एंड उससे क्या

play26:46

होगा हमारा जो 1mb का जेएस बंडल साइज है

play26:49

वो हो सकता है सिर्फ 0.2 m का रह जाए तो

play26:52

जिससे क्या होगा हमारा जो पेज लोड है वो

play26:54

और ज्यादा फ होता जाएगा ओके लोडिंग स्पीड

play26:56

हमारी बहुत ज्यादा फास्ट होती जाएगी स वी

play26:59

हैव टू बी वेरी कॉशस दैट हम किस पर्टिकुलर

play27:01

चीज को यूज़ क्लाइंट कर रहे हैं बिकॉज़

play27:03

अगर हम किसी भी कंपोनेंट को यूज़ क्लाइंट

play27:05

करते हैं आंड वो क्लाइंट बहुत हैवी है तो

play27:07

पूरा का पूरा जेएस बंडल साइज हमारा

play27:09

इंक्रीज हो जाएगा एंड ओवरऑल हमारी वेबसाइट

play27:11

स्लो हो सकती है तो ये पूरा कंसेप्ट है

play27:14

सर्वर कंपोनेंट्स का सो दैट ऑल फॉर दिस

play27:17

वीडियो तो इस वीडियो में हमने बात किया

play27:18

व्हाट आर सर्वर कंपोनेंट्स व्हाट आर सर्व

play27:20

साइड रेंडरिंग सो आई होप दैट वीडियो अच्छा

play27:23

लगा होगा सो वीडियो अच्छा लगा तो लाइक एंड

play27:25

सब्सक्राइब जरूर करना मिलते हैं हम आपको

play27:26

नेक्स्ट वीडियो के अंदर

play27:28

अंट्या टेक केयर

Rate This

5.0 / 5 (0 votes)

Связанные теги
React ComponentsServer-Side RenderingWeb OptimizationNext.jsJavaScript FrameworkFrontend DevelopmentBackend RenderingCode HydrationPerformance TipsDevOps Strategies
Вам нужно краткое изложение на английском?