Move the JS code to a JS file and make the animation code a bit cleaner.
Make sure the JS is included with an absolute path.
Don't try to execute the animation if the heart doesn't exist.