Web Design Forum: Loading content with ajax causes images and layout to flicker - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Loading content with ajax causes images and layout to flicker

#1 User is offline   kirky_D 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 72
  • Joined: 21-October 10
  • Reputation: 1
  • Gender:Male
  • Location:Preston, UK
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 06 February 2012 - 10:35 PM

Hi there.

I'm currently trying to have my site navigate by using ajax from jquery to load in a file from the server and replace the contents of the current page. The problem I'm having is that the layout of the newly retrieved html has yet to be formatted correctly by the browser before the user can see it. This is especially troublesome when images are concerned because before the image is loaded the browser doesn't know it's size and the content gets all shifted around once it has loaded.

Is there a way to load html content (including all images that it references) before displaying it?

Here is the website, the only 2 links that work are 'home' and 'new'. Pay attention to the flicker when you FIRST click 'new'. After it has loaded the first time it ends up looking really good, but this first time is horrible.

http://kdwebdesign.c...cts/andy_croft/

Any idea how I can solve this issue?

Thanks all!
0

#2 User is online   Spitfire 

  • Mighty Pirate™
  • PipPipPipPip
  • Group: Members
  • Posts: 891
  • Joined: 05-February 11
  • Reputation: 189
  • Gender:Male
  • Location:Berkshire
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 08 February 2012 - 03:11 PM

Just give all your images height and width attributes - http://www.w3schools...t_img_width.asp

Then the browser will know their size before rendering them.
0

#3 User is online   Sogo7 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 421
  • Joined: 02-February 11
  • Reputation: 42
  • Gender:Male
  • Location:Camarthen
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 08 February 2012 - 03:29 PM

There are three ways to preload image content but the smallest and least code invasvive method is via the CSS see:

http://perishablepre...out-javascript/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users