Web design and Advertisements

Recommended Videos

Koshok

New member
Jan 22, 2011
119
0
0
So lately I've been taking note of how web pages load, particularly when things are running slowly. I've noticed that most of the time, a web page will partially load, then wait for advertisements to load, then load the content I actually want to see. The result is that the ad has to load before I can actually enjoy the page. I'm honestly curious why this is the case. Wouldn't it be in everyone's best interest if ads were loaded last?
Now, I have AdBlocker, but I always turn it off on sites that I frequent, like the Escapist. When I turn on AdBlocker, just about every site I go to loads much faster than without it. This seems like an encouragement to block advertising, which would harm the web site. I'm wondering what people's thoughts on this are, particularly people who know web design.
(And I do apologize to the mods in advance if this breaks the forum rules.)
 

Lucem712

*Chirp*
Jul 14, 2011
1,470
0
0
I'd advise you to be careful, you aren't allowed to mention those things, regardless if you are sponsoring them or not.
 

DoPo

"You're not cleared for that."
Jan 30, 2012
8,663
0
0
Koshok said:
I'm honestly curious why this is the case. Wouldn't it be in everyone's best interest if ads were loaded last?
That...would be a very complex issue. I don't have perfect knowledge of webpage loading orders [footnote]and, frankly, it's not something I'd really want to be able to say "I know how it works" it will just be...sad, I guess[/footnote] but I believe it goees sort of like this - the HTML is downloaded and parsed. Elements are loaded into the DOM in order. Also, when each element is loaded it's also downloaded, if needed. So, since ads tend to be further up than the actual content (at least when it comes to the HTML), it would make sense for them to be loaded faster. And since the ads are larger objects, they would slow down everything after them and "appear" first. However, that tends to not be a problem when you take into account asynchronous loading. Well, it depend on how many simultaneous requests can you have. If I remember correctly, Firefox does limit them down to something like 6 or so.

Now, here is something I just came across (and, yes, it now makes me sad I know it) "The execution is top down and single threaded. Javascript may look multi-threaded, but the fact is that Javascript is single threaded. This is why when loading external javascript file, the parsing of the main HTML page is suspended." which would explain the ads - a lot of them are javascript.

I'm not exactly sure how external frames go, and for the sake of my state of happiness, I don't want to check it, but I suspect they would have a similar approach - when parsed, they are loaded into the DOM in top-down order. But the frames would also be treated as a webpage and they would go through a similar process as the parent page. It is a very high chance that they wouldn't get a separate thread, but the HTML parser that works on the parent page will temporary suspend work and go over the frame before jumping back in. Now this is just speculation and the behaviour may vary across browsers, but it's a possibility and it would further explain why ads are loaded first.

Moreover, if it's a website you visit frequently, your browser may have most elements cached, sans the ads which are required to be dynamic. This will make it vaguely seem like ads are slowing down stuff, but basically, ads will require to be downloaded each time, while the rest of the page (or parts of it, at least) will not be re-loaded every time.

It would help if you can show me a page that has ads loading first, so I can check over it. Or even you can do it yourself - install Firebug and if you go to the Net panel, you'll see the load order and time for the elements. I'm not sure what can be used for other browsers but there will be something.

And now, finally, would it be better, if ads loaded last - that, too, is a complicated issue. First of all, it's just plain easier to have a page template with the content near the bottom. It's what most people would do without thinking. Just a matter of convenience. This is what I'd do, without thinking, too. But moving the ads to the bottom requires further research. Also, it's not recommended to have JavaScript files and just general external inclusions down in the body section of the page. Well, all modern browsers would work with it, still people try to avoid it from what I've seen. And another thing - having the ads load last (or later) may mean you miss out on hits on them. And that's something you don't want, if you have ads.

OK, I didn't mean to just technobabble but you can see that it's not something really easy to answer. I'd need more research to answer that definitively and I've worked as a web developer (although we didn't have ads on out sites).

EDIT: And one thing I forgot to mention, but meant to - it's not something many web developers will think about in such depth. A website works, so great! Not to mention that most times you wouldn't be worried about the load time of a web page, simply because you're working under the assumption that people aren't on dial-up modems any more, so, as long as the page size is reasonable (say, not more than a megabyte) there isn't need for much optimisation.
 

Koshok

New member
Jan 22, 2011
119
0
0
DoPo said:
Thanks for the explanation. I think I understood most of what you said, and it definitely helped me understand what's going on.