Unloading Resources on HTML with JavaScript

前端 未结 5 986
無奈伤痛
無奈伤痛 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:13

    There are 2 better ways to load images besides a normal tag, which Google brilliantly discusses here:

    http://www.youtube.com/watch?v=7pCh62wr6m0&list=UU_x5XG1OV2P6uZZ5FSM9Ttw&index=74

    1. Loading the images in through an HTML5 which is way way faster. I would really watch that video and implement these methods for more speed. I would imagine garbage collection with canvas would function better because it's breaking away from the DOM.

    2. Embedded data urls, where the src attribute of an image tag is the actual binary data of the image (yeah it's a giant string). It starts like this: src="data:image/jpeg;base64,/9j/MASSIVE-STRING ... " After using this, you would of course want to use a method to remove this node as discussed in the other answers. (I don't know how to generate this base64 string, try Google or the video)

提交回复
热议问题