0

Case: Our site has many ads block from different publishers and we have placed them on different regions of our sites homepage. They are mainly banner ads.

Problem: Site loads very slow and takes about 15 - 20 sec on an average.

Is there are any ways to improve the placement of scripts of ads ??

echo
  • 297
  • 2
  • 10
  • 2
    Have them load asynchronously. – gpojd Aug 21 '15 at 14:56
  • Ok, we have defered all are ads script, but the same problem. – echo Aug 21 '15 at 14:57
  • 2
    You could move them into another file called "ads.html" and forget about them. It's a win/win for both you and your users. – Pierre Aug 21 '15 at 14:58
  • "defer" and "async" do two different things. – gpojd Aug 21 '15 at 14:59
  • 1
    You don't have enough information. You need to look at your network inspector and determine what the problems are. Then address them in order of priority. You probably have a blocking script in your `` that is responsible for a lot of this issue. – Darth Egregious Aug 21 '15 at 15:02
  • @gpojd yes we got your point thank you :) They load asynchronously now, also We have moved all java scripts to just before end of body tags also. Our DOM loads quite well, but seems like browser keeps on loading the site and waits for some ads to load. – echo Aug 22 '15 at 03:12

2 Answers2

0

15-20 is totally unacceptable. Ads are typically included with a JavaScript file (supplied by the ad vendor) which will load the resources for the ad.

If the script takes long to load it will block all other JavaScript on the website because browsers will wait until all scripts are loaded. In this case you can delay loading of the script file either by adding defer or adding the script dynamically with JavaScript. See: How to Append <script></script> in javascript?

If the ad resources take long to load it shouldn't impact other aspects of the site. From a UX perspective make sure the ads don't pop in and move other elements when they are finally loaded. You can do this by making sure their space is already allocated.

You can use the Network/Net tab in Chrome/Firebug to see which resources are loading when and see when the browser is read to run JavaScript etc.

Community
  • 1
  • 1
Halcyon
  • 57,230
  • 10
  • 89
  • 128
0
  1. Create a queue for the ad scripts.
  2. Process that queue after all of your other operations are completed.
  3. Advertisers want to "appear sooner?" Charge more for priority.

Without code, thats about as specific as I can get. Good question!

Brandt Solovij
  • 2,124
  • 13
  • 24