These snippets will get the height and width of an image, one when it is loaded and another when the image is not loaded yet.
Check whether a number is odd or even using the modulo (%) operator. Return true if the number is odd, false if the number is even.
To select elements by a given class name, you use the getElementsByClassName() method
This snippet stops or pauses YouTube, Vimeo and HTML5 videos when the content area is close
This snippet gets the height of an iframe’s content and then sets the height of the iframe to match.
Use Math.pow() to calculate x to the power of 1/n which is equal to the nth root of x.
Select an element that matches the id using the getElementById() method.
Here is a vanilla JS alternative to the moment.js timeFromNow() method.
This function serializes the form data which consists of names and values of its fields.
Use Math.max() and Math.min() to find the closest safe value. Use Math.round() to convert to an integer.