Перебирал я как-то старые закладки. Накопилось же всякого. Ну, например, куча ссылок по борьбе с утечками памяти:
- Практический JS: избавляемся от утечек памяти в IE
- Как избавиться от утечки памяти при использовании Javascript в Internet Explorer
- JavaScript Memory Leak Detector
- IE Memory Leaks
Типичный пример кода:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$("#gmap").load(function() {
$("#loading").hide();
$(this).show();
});
$("#hmap").load(function() {
$(this).show();
}).attr("src", "hs.png");
$("#hublist").bind("change keyup", function() {
with ($("#gmap")) {
var newurl = 'http://maps.google.com/staticmap?zoom=5&size=640x640&format=png8¢er=' +
["57,40", "50,41", "57,42", "57,43", "57,48", "57,49"][this.value - 1];
if (attr("src") != newurl) {
$("#loading").show();
attr("src", newurl);
}
}
}).focus().change();
</script>
В общем, применение jQuery дает чистый, стабильный код.
<script type="text/javascript">
$("#gmap").load(function() {
$("#loading").hide();
$(this).show();
});
$("#hmap").load(function() {
$(this).show();
}).attr("src", "hs.png");
$("#hublist").bind("change keyup", function() {
with ($("#gmap")) {
var newurl = 'http://maps.google.com/staticmap?zoom=5&size=640x640&format=png8¢er=' +
["57,40", "50,41", "57,42", "57,43", "57,48", "57,49"][this.value - 1];
if (attr("src") != newurl) {
$("#loading").show();
attr("src", newurl);
}
}
}).focus().change();
</script>
В общем, применение jQuery дает чистый, стабильный код.
1 коммент.:
как минимум $.fn.html течёт безбожно =(
Отправить комментарий