defer="defer" compatible?

Page: 1

Author Post
Member
Registered: May 2011
Posts: 17
To try to improve page load time, I tried loading floatbox up using the "defer" argument:
<script type="text/javascript" src="/floatbox/floatbox.js" defer="defer"></script>

but unfortunately, the floatbox elements don't light up like I thought they would but instead they stay dead.

I'm assuming that floatbox doesn't detect the document ready signal. So I'm trying to light up everything via fb.activate inside the jquery .ready function:

$(document).ready(function(){
// Light up the defered floatbox items
fb.activate;
});

Here's an example:
http://www.interplas.com/?defer
click on Satisfaction Guarantee.

Any help is greatly appreciated!
Administrator
Registered: Aug 2008
Posts: 3382
Floatbox won't work in most browsers if loaded with "defer". It sets itself up on DOMContentReady. If loaded after the DOM is ready it will just sit there deaf, dumb and blind waiting for DOMContentReady to wake it up. Don't use "defer".

Move the floatbox.js (and other scripts) to the bottom of the <body> element if you want to slightly improve the apparent page load time. The reason why the docs recommend placing floatbox.js in the <head> is so that its API functions are available to the page while the page is loading.

Page: 1