Home Largest Contentful Paint element snippet-item r-snippetized Skip to main content

Largest Contentful Paint element snippet-item r-snippetized



// AJAX se content load karna

function loadFeaturedPost() {

  var xhttp = new XMLHttpRequest();

  xhttp.onreadystatechange = function() {

    if (this.readyState == 4 && this.status == 200) {

      document.getElementById("featured-post-container").innerHTML = this.responseText;

    }

  };

  xhttp.open("GET", "URL_OF_YOUR_FEATURED_POST_CONTENT", true);

  xhttp.send();

}


// Preload function

function preloadFeaturedPost() {

  if (document.readyState === 'complete') {

    loadFeaturedPost();

  } else {

    window.addEventListener('load', loadFeaturedPost);

  }

}


// Call preload function

preloadFeaturedPost();



Comments

Lazy Loading Example Preloaded Image Another Preloaded Image