Efficient Loading of Banner Advertisements with Jquery
💻 coding

Efficient Loading of Banner Advertisements with Jquery

1 min read 211 words
1 min read
ShareWhatsAppPost on X
  • 1The article explains how to load banner advertisements efficiently using jQuery to improve web page loading speed.
  • 2It provides a simple AJAX implementation that loads the main content first, followed by the top and side banners.
  • 3The code includes jQuery functions for loading content and banners, along with necessary HTML and CSS structures.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"The article explains how to load banner advertisements efficiently using jQuery to improve web page loading speed."

Efficient Loading of Banner Advertisements with Jquery

Banner advertisements eating your web page loading time? Take a look at this post. how to display advertisiment blocks after loading the main content block with jquery. It is very simple ajax implementation with jquery. Use it increase your web project loading speed.

Content block loading first then Topbanner finally Sidebanner

Javascript Code

Contains javascript code. Using jquery ajax function.

<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
content(); // 1 content block
topbanner(); // 2 top banner
sidebanner(); // 3 side banner

//Content Block
function content() 
{
$.ajax({
type: "POST",
url: "content.php", //Content Page
data: "" , 
beforeSend: function() 
{
$("div#content").html('<span class="loading">Loading...</span>');
},
cache: false,
success: function(data)
{ 
$("#content").html(data);
}
});
}

//Top Banner Block
function topbanner() 
{
$.ajax({
type: "POST",
url: "topbanner.php", //Top banner File
data: "" , 
beforeSend: function() 
{ 
$("div#topbanner").html('<span class="loading">Loading...</span>'); 
},
cache: false,
success: function(data)
{ 
$("#topbanner").html(data);
}
});
}
//Side banner funtion same like topbanner.

});
</script>

//HTML Code

<div id="main">
<div id="topbanner"></div>
<div id="content"></div>
<div id="sidebanner"></div> 
</div>

topbanner.php

Contains PHP and HTML code

<?php
echo '<a href=""><IMG src="topbanner.png" /></a>';
?>

CSS Code

#main
{
width:900px; border:solid 2px #dedede; margin-top:30px; height:600px
}
#topbanner
{
height:100px; border-bottom:solid 2px #dedede
}
#content
{
float:left;width:750px; height:498px
}
#sidebanner
{
float:left;width:148px; height:498px;border-left:solid 2px #dedede
}
.loading
{
color:#cc0000;
}

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 14 August 2019 · 1 min read · 211 words

Part of AskGif Blog · coding

You might also like

Efficient Loading of Banner Advertisements with Jquery | AskGif Blog