The primary use of JavaScript is to write functions that are embedded in or included from HTML pages and that interact with the Document Object Model (DOM) of the page.

snippet - Javascript: object keys and values to html table
14 Jun, 2021
Convert javascript object into html table, where keys are in the first column and values are in the second column. This uses plain javascript so you can use it anywhere.
snippet - Explode / split string in ES6
15 Jul, 2020
How to split string in ES6. I would suggest the method of using split function from lodash. In modern JavaScript frontend you use a lot of dependencies and lodash is used in almost every project....
snippet - Validate Date in JavaScript
15 Apr, 2020
How to find out if a Date is indeed a valid Date. Simply instance check will not do it, the date might be "Invalid Date".
snippet - Create and Post HTML Form using Javascript
20 Mar, 2019
This snippet creates html form and submits it, the same way as browser submits form "with redirect". If you need the redirect not an ajax solution, for example credit card payment.
snippet - Convert to Integer in JavaScript
8 Nov, 2018
There are multiple ways to convert values to integer in javascript. Using Math.trunc gives the most accurate results.
snippet - Webpack: Remove comments from compressed css
1 Jun, 2017
You can minify css with optimize-css-assets-webpack-plugin, but by default some comments are left untouched. If you want to remove all comments you have to use an option for the cssnano, that is used...
snippet - Javascript: move item to end of array (of objects), by property value
29 May, 2017
The snippet shows how to move item to the end of array. In a case where we have an array of objects and we want to move the array item by property value. In this example I am using lodash/underscore...
snippet - JavaScript ES6: Clone Object
13 May, 2017
The Object.assign() method copies all properties from one or more source objects to a target object. It returns the target object. This can be used for cloning an object in ES6, just create an empty...
snippet - webpack: Minify CSS in production
14 Mar, 2017
You can achieve this by adding a library that supports css minify to "webpack.config.js". In this snippet I use "optimize-css-assets-webpack-plugin" which uses cssnano for minimizing by default. The...
snippet - Delete object key and value in javascript
12 Oct, 2016
Deleting object value with key in javascript. For this you can use the delete operator. Permits you to remove a property from an object.
snippet - Minify JavaScript from command line
8 Mar, 2016
This snippet shows how to minify javascript files from command line. Minifying JavaScript is useful in many respects. Most important are security and performance. Security is increased due to the...
snippet - Get previous / next element using JavaScript
8 Mar, 2016
This snippet shows how to get element next to your element / selector. This a part of dom traversal. Using javascript for next element parsing can be used to create some powerful dynamic content. I...
snippet - AddThis: Popup instead of hover box
25 Nov, 2015
AddThis is an awesome social sharing tool. It is fully customizable. I suggest using addthis module for loading add this library, this has performance options for the javascript loading.
snippet - Get cursor position in CKEditor
12 Jun, 2015
Get cursor position in CKEditor is simple if you know some facts. You have to have the instance initiated, so simple jQuery ready would not work. You can get selection and use that functionality to...
snippet - Alter URL GET parameters using JavaScript
14 Aug, 2013
This function alters url get parameters using javascript. The function takes to consideration all aspects of url (parameter existis, hash, parameter doesn't exist). For an example if you need to be...
snippet - jQuery - Check if selector is disabled
7 Mar, 2013
You can use "is" to see if the form element is disabled.
snippet - Message before leaving the page - JavaScript / jQuery
8 Feb, 2013
How to display message before closing the page or moving to another page. Don't use this to annoy people. Sometimes this functionality is still useful, for an example if you have some sort of unsaved...
snippet - Get URL variables with JavaScript
21 Nov, 2012
This function gets URL variables in JavaScript. Current page url parameters will be parsed into array, that will be returned.
snippet - Monochrome Google Maps
19 Nov, 2012
This example shows how to create monocrome Google Maps. Where the map will be using only shades of grey (with or without black and/or white). It might also be called grayscale or black-and-white.
snippet - Round numbers in JavaScript
1 Oct, 2011
This snippet shows you how to round a number to a specified number of decimal places in JavaScript.
snippet - Print JavaScript object
21 Sep, 2011
This snippet shows how to print JavaScript object.
snippet - Redirection in JavaScript
16 Aug, 2011
There are many ways of doing redirect in JavaScript this should be the standard implementation for changing the current window's location.
written tutorial - Switching Images With Arrows in JavaScript
7 Apr, 2011
This tutorial shows how to make image switcher with javascript. You can switch images by using arrows.
written tutorial - Loading AJAX Page / Dynamic Content
25 Aug, 2010
Tutorial about loading page with AJAX between any HTML tags. We are using jQuery JavaScript library to do this.