The first image makes use of the JavaScript built inside the image.

The second uses JavaScript from a function already pre-loaded. The function can also be loaded in an external JavaScript file.