Unloading Resources on HTML with JavaScript

前端 未结 5 987
無奈伤痛
無奈伤痛 2020-12-29 07:23

I\'m working on a HTML 5 game, it is already online, but it\'s currently small and everything is okay.

Thing is, as it grows, it\'s going to be loading many, many im

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 08:12

    All right, so I've made my tests by loading 3 different HTML into an < article > tag. Each HTML had many, huge images. Somewhat about 15 huge images per "page".

    So I used jQuery.load() function to insert each in the tag. Also had an extra HTML that only had an < h1 >, to see what happened when a page with no images was replacing the previous page.

    Well, turns out the RAM goes bigger while you start scrolling, and shoots up when going through a particularly big image (big as in dimensions and size, not just size). But once you leave that behind and lighter images come to screen, the RAM consumption actually goes down. And whenever I replaced using JS the content of the page, the RAM consumption went really down when it was occupying to much. Virtual Memory remained always high and rarely went down.

    So I guess the browser is quite smart about handling Resources. It does not seem to unload them if you leave it there for a long while, but as soon you start loading other pages or scrolling, it starts loading / freeing up.

    I guess I don't have anything to worry about after all...

    Thanks everyone! =)

提交回复
热议问题