Categories
Javascript / JQuery Snippets

Docker file for Express App with PM2

FROM node:10 WORKDIR /usr/src/app COPY package*.json ./ RUN npm install pm2 -g RUN npm install COPY . . EXPOSE 8080 CMD [“pm2-runtime”, “server.js”]

Categories
Javascript / JQuery Snippets

Difference between two date in JavaScript

Let us see an example of how to calculate the difference between dates using Javascript. First, write an HTML code with Javascript as below:

Categories
Javascript / JQuery Snippets

Use for() instead Array.forEach(), for() is 95% faster

Array.ForEach is about 95% slower than for() in for each for Arrays in JavaScript. So, don’t use: Use: See this performance test online: http://jsperf.com/fast-array-foreach

Categories
Javascript / JQuery Snippets

JavaScript – How to check number is odd or even

Here is the simple JavaScript code snippet to check if the given number is an odd or even number. Function to check Number Is Odd Or Even How to use checkEven

Categories
Javascript / JQuery Snippets

JQuery Preload Images

jQuery make it easy to preload images in the background so visitors won’t have to wait forever when they would like to display an image. This code is ready to use, just update the image list on line 8.

Categories
Javascript / JQuery Snippets

Toggle class on hover

Categories
Javascript / JQuery Snippets

Fix broken images automatically

Occasionally we have times when we have broken image links on our website and replacing them one by one isn’t easy, so adding this simple piece of code can save you a lot of headaches.

Categories
Javascript / JQuery Snippets

Append New HTML

Categories
Javascript / JQuery Snippets

Equal Column Heights

Categories
Javascript / JQuery Snippets

Scroll to Top

Categories
Javascript / JQuery Snippets

Prevent Anchor Links from Loading

Categories
Javascript / JQuery Snippets

JQuery Check if Element Exists

Categories
Javascript / JQuery Snippets

Check for Empty Elements

Categories
Javascript / JQuery Snippets

JQuery Adding/Removing Class on Hover

Categories
Javascript / JQuery Snippets

Google Webfonts and performance fix