Jquery – Lazy load content for speed and SEO benefits

Another way to speed up your page loads and neaten up the HTML that search spiders see is to lazy load whole chunks of it using an AJAX request after the rest of the page has loaded.

The user can get browsing right away and spiders only see the content you want them to index.

We just put all that HTML in a static page and use the load() function to load it in once the DOM was ready.

Example:

$('#forms').load('content/headerForms.html', function() {
  // Code here runs once the content has loaded
  // Put all your event handlers etc. here.
});

You have to consider the trade offs here. You’re making extra requests to the server and portions of your page might not be available to the user right away, but used correctly it can be a great optimization technique.

Leave a Reply

Your email address will not be published. Required fields are marked *

*