justanotherhobbyist
justanotherhobbyist

Reputation: 2192

What is faster when comparing image vs javascript?

I'm wondering if there is a big difference when loading graphics made in pure javascript or using a large image.

As reference i made this example on jsFiddle. From a performance perspective what is best, drawImage using a png image or drawing it using javascript?

Upvotes: 2

Views: 147

Answers (1)

Tei
Tei

Reputation: 1416

For complex images, rendering will be slow, because javascript is slow itself. For hundreds of small images, using a img tag will probably be very fast.

The only way to kill perfomance is by having a "javascript that run very long", because is blocking (and that can be avoided with some worker/consumer pattern), or having gigantic images with alpha transparency.

Future versions of Chrome and Opera will have a profiler for CSS/rendering, that will tell you exactly how much and what is taking more time to render.

Upvotes: 1

Related Questions