Tips for delaying the loading of a video until after the initial page load in React/NextJS

I am looking to improve my lighthouse scores by delaying the loading of a video until after the page has completely loaded. Since the video is below the fold and only visible upon scrolling, I want it to wait for everything else on the page to load first in order to achieve a fast FCP (First Contentful Paint), and then load the video afterwards.

However, this approach does not seem to be effective in terms of enhancing my Lighthouse score...

export default function AboutUs() {
  const [loadVideos, setLoadVideos] = useState(false)

  useEffect(() => {
    setLoadVideos(true)
  }, [])

   .....etc etc.....

    {loadVideos && (
          <video
            autoPlay
            muted
            playsInline
            loop
            preload="none"
            poster="/images/charge_poster.jpg"
          >
            <source src="/videos/charge.mp4" type="video/mp4" />
          </video>
        )}
   ..Closing tags etc

Is there a more efficient way to achieve this goal? I prefer not to load the video on scroll as it would result in the video loading while the user is already viewing the content. Ideally, I would like the video to load after the HTML, CSS, and Images have loaded.

Thank you

https://i.sstatic.net/mcqUn.png

Answer №1

If autoplay is included, the preload attribute will be disregarded.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Removing information from a database using the delete function

I'm currently facing an issue while trying to delete an item from the database using a button that calls a delete function. Everything seems to be working fine, and I can see the API call for deletion in the console. However, the req.body is coming up ...

Unable to configure raycaster layers within Three.js framework

While attempting to configure the raycaster layer to only cast on a single layer, as outlined in the threejs documentation: - I encountered the following error Uncaught TypeError: Cannot read properties of undefined (reading 'set') What could b ...

Steps to deactivate a particular date on the Jquery UI datepicker:

I am struggling to disable specific dates (20, 21, 25 OCT 2015) using the JQuery UI datepicker. Despite my efforts, I have not been able to achieve the desired output. Below is a snippet of my code for reference. <!doctype html> <html lang="en" ...

Removing information from the app.component.html file in Angular 6 and reflecting those updates in the view

I currently have a service that retrieves a list of data and displays it within the app.component.html. Below is the code snippet used to display the data: <ul> <li *ngFor="let data of retrieveData"> {{ data.id }} - {{data.title} ...

Adjusting Javascript code to launch a URL in a new window or new tab depending on the user's selection

I seem to be encountering a puzzling issue with a link on my website. When clicked normally, the link opens in a new window. However, if I right-click and select "open in new window" or "open in new tab," it just reloads the same page where the link was cl ...

Create a JavaScript program that can identify which number in a given array is different from the other two when two of the numbers in the array are equal

function checkThirdNumber() { let num1 = parseInt(document.querySelectorAll('.checkThirdInput')[0].value); let num2 = parseInt(document.querySelectorAll('.checkThirdInput')[1].value); let num3 = parseInt(document.querySelect ...

Why is the message "not found" appearing when I try to refresh the Next.js page?

After clicking on the link, my blog pages load successfully, but upon refreshing the page, it shows as not found. path: -blog / [id].js [id].js class Post extends React.Component { constructor(props) { super(props); thi ...

What is the reason behind Istanbul's code coverage reporting a switch statement as uncovered even though all conditional paths are covered?

Within my node.js application, there is a class that includes a getter method with a significant switch statement. Rather than the simple example provided below, this switch statement contains numerous unreleased product-specific values replacing 'a&a ...

Using React hooks and Typescript: I was expecting to see an assignment or function call, but instead, an expression was

After working as a React developer for quite some time, my workplace recently introduced Typescript, which I am still getting familiar with. I implemented a custom hook for managing cookies, but the function it returns is generating an error. Here's ...

Managing selected ticket IDs in a table with AngularJS

I have a table that includes options for navigating to the next and previous pages using corresponding buttons. When I trigger actions for moving to the previous or next page (via controller methods), I store the IDs of checked tickets in an array $scope. ...

Mastering the art of Puppeteer with Javascript

I am currently learning how to make web requests using JavaScript with puppeteer. After some trial and error, I was able to extract the value of a tag from a random website. However, I am struggling to figure out how to retrieve 10 consecutive values of ...

Tips for maintaining a marker at the bottom of the screen while zooming, similar to Google Maps

Is there a way to customize the zoom behavior in my project? I want to maintain the bottom position while resizing the other three directions, and also include pitch adjustments. https://i.sstatic.net/hQdg8.gif https://i.sstatic.net/m3xef.gif I aim for t ...

Retrieving row and column values from an 81-element indexed array

I am working with an indexed JavaScript array that contains exactly 81 elements. These elements will form a 9x9 grid, similar to a Sudoku puzzle. Right now, I am trying to figure out the most efficient way to extract row and column values from this array. ...

Generating dynamic dropdown menus in PHP

I'm currently working on a project that involves creating dynamic drop down lists in PHP using JavaScript. I've managed to fetch the value from the first dropdown list and display the corresponding values in the second list. However, the second l ...

Execute a self-invoking JavaScript function with dynamic code

I'm facing a challenging problem that I just can't seem to solve... There's a function on another website that I need to use, but unfortunately, I can't modify it The code in question is: Now, I am looking to add a prototype "aaa" to ...

Tips for creating a dynamic variable for an object key in jQuery to streamline your code

Utilizing the TweenMax library, I am adding styles to a div while scrolling. However, I am facing a challenge where I need different styles based on varying page resolutions. To address this issue, I implemented an if condition. Is there a way I can use a ...

Discovering the method to access query parameters in a node.js module

Creating a straightforward pagination module for an express app is essential. Here's an example of the code I have implemented: var config = require('../config'); function Pagination(options) { this.param = options.param || 'page ...

What are the steps to ensure that $.getScript functions properly?

It seems like the $.getScript function in jQuery will be really helpful once it's functioning properly, but I'm having some trouble with the last part. I have a feeling that the issue is related to how I'm loading JS files. How can I resolve ...

Utilizing mixins with async components in VueJS

Currently, I am utilizing Webpack 2 to import components using a special syntax with require. Among the over 100 components available, only around 5-10 are used at any given time. These components share some common functionality such as props and lifecycl ...

Monitoring Clicks within an Iframe

Is there a way to track a click event on a hyperlink within an iframe using Google Analytics? The iframe is located within the same domain as the main page. How can this be achieved? The iframe is added dynamically to the page after it has loaded. Is i ...