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

Website load enhancement #368

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';
import React, { useState, Suspense, lazy } from 'react';
import Navbar from './components/Navbar';
import Home from './components/Home';
import AboutUs from './components/AboutUs';
import DemoSection from './components/DemoSection';
import ContactUs from './components/ContactUs';
import Models from './components/Models';
import Preloader from './components/Preloader';
import GoToTop from './components/BottomToTop';

// Lazy load components
const Home = lazy(() => import('./components/Home'));
const AboutUs = lazy(() => import('./components/AboutUs'));
const DemoSection = lazy(() => import('./components/DemoSection'));
const ContactUs = lazy(() => import('./components/ContactUs'));
const Models = lazy(() => import('./components/Models'));

const App = () => {
const [loading, setLoading] = useState(true);

Expand All @@ -20,24 +22,21 @@ const App = () => {
{loading ? (
<Preloader onLoaded={handleLoaded} />
) : (
<>
<Navbar />
<Home />
<GoToTop />
<hr/>

<DemoSection />
<ContactUs />
<AboutUs />
<Models/>
</>
<Suspense fallback={<div>Loading...</div>}>
<>
<Navbar />
<Home />
<GoToTop />
<hr />
<DemoSection />
<ContactUs />
<AboutUs />
<Models />
</>
</Suspense>
)}

</div>
);
}

export default App;



51 changes: 26 additions & 25 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
import React from "react";
import React, { Suspense, lazy } from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Home from "./components/Home";
import AboutUs from "./components/AboutUs";
import DemoSection from "./components/DemoSection";
import ContactUs from "./components/ContactUs";
import Navbar from "./components/Navbar";
import Models from "./components/Models";
import Custom404 from "./components/Custom404";
import "./main.css";
import Privacy from "./components/Privacy";
import Licensing from "./components/licensing.jsx";
import Terms from "./components/Terms";
import ChatbotComponent from "./components/Chatbot"; // Import Chatbot
import Preloader from "./components/Preloader";
import App from './App.jsx';
import ChatbotComponent from "./components/Chatbot"; // Import Chatbot

// Lazy load components
const Home = lazy(() => import("./components/Home"));
const AboutUs = lazy(() => import("./components/AboutUs"));
const DemoSection = lazy(() => import("./components/DemoSection"));
const ContactUs = lazy(() => import("./components/ContactUs"));
const Models = lazy(() => import("./components/Models"));
const Privacy = lazy(() => import("./components/Privacy"));
const Licensing = lazy(() => import("./components/licensing.jsx"));
const Terms = lazy(() => import("./components/Terms"));

ReactDOM.createRoot(document.getElementById("root")).render(
<Router>

<Preloader />
<Navbar />{" "}
{/* Place Navbar outside of Routes to ensure it's always visible */}
<Routes>
<Route exact path='/' element={<Home />} />
<Route exact path='/AboutUs' element={<AboutUs />} />
<Route exact path='/DemoSection' element={<DemoSection />} />
<Route exact path='/ContactUs' element={<ContactUs />} />
<Route exact path='/Models' element={<Models />} />
<Route exact path='/privacy-policy' element={<Privacy />} />
<Route exact path='/licensing' element={<Licensing />} />
<Route exact path='/terms-and-conditions' element={<Terms />} />
<Route path='*' element={<Custom404 />} />
</Routes>
<Navbar /> {/* Place Navbar outside of Routes to ensure it's always visible */}
<Suspense fallback={<div>Loading...</div>}>
<Routes>
<Route exact path="/" element={<Home />} />
<Route exact path="/AboutUs" element={<AboutUs />} />
<Route exact path="/DemoSection" element={<DemoSection />} />
<Route exact path="/ContactUs" element={<ContactUs />} />
<Route exact path="/Models" element={<Models />} />
<Route exact path="/privacy-policy" element={<Privacy />} />
<Route exact path="/licensing" element={<Licensing />} />
<Route exact path="/terms-and-conditions" element={<Terms />} />
<Route path="*" element={<Custom404 />} />
</Routes>
</Suspense>
<ChatbotComponent /> {/* Include Chatbot */}
</Router>
);