Simple Countdown Timer In Vanilla JavaScript – ysCountDown.js

Category: Date & Time , Javascript | August 9, 2018
Views Total:4,019 views
Official Page:Go to website
Last Update:August 9, 2018


Simple Countdown Timer In Vanilla JavaScript – ysCountDown.js


ysCountDown.js is a simple JavaScript countdown timer plugin for counting time down in DAYS, HOURS, MINUTES, SECONDS.

How to use it:

Insert the minified version of the ysCountDown.js library into the html file.

<script src="dist/yscountdown.min.js"></script>

Create a container element for the countdown timer.

<p id="counter"></p>

Set the end date the countdown timer will count down from.

var endDate = "2018/12/25";

Render the countdown timer inside the container element you created.

var counterElement = document.querySelector("#counter");
var myCountDown = new ysCountDown(endDate, function (remaining, finished) {
    var message = "";
    if (finished) {
      message = "Expired";
    } else {
      message = remaining.totalDays + " d ";
      message += remaining.minutes + " m ";
      message += remaining.seconds + " s ";
    counterElement.textContent = message;

Download and checkout the examples folder for more examples.

You Might Be Interested In:

Leave a Reply