Thursday, 28 January 2010

jQuery moment [.empty() BEFORE .load()]

OK I know its probably jQuery 101 stuff but I have been writing things like this.

var loadingimage = '';

$('#divID').html(loadingimage)
.load(url)

It works, it works fine, but after a while you are going to eat up memory.


Now, this is just blanking the content and not actually deleting the content from memory, what I should be doing is this:

var loadingimage = '';

$('#divID').empty()
.html(loadingimage)
.load(url)

Lesson learnt, for head slapped.

0 comments:

Post a Comment