Homepage
Code Showcase

Javascript Calendar

A simple lightweight (<3KB) event-driven pure JavaScript plugin to generate calendars.

JavaScript

Javascript Calendar

A simple lightweight (<3KB) event-driven pure JavaScript plugin to generate calendars.

Unlike the jQuery Calendar below, this doesn't require jQuery - in fact, it has no depenencies at all.

You can view this project on Ben's GitHub account: https://github.com/benhall14/javascript-calendar

Javascript Calendar

A simple lightweight (<3KB) pure javascript to generate calendars.

You can pass events using optional parameters.

File Size is less than 3 KB - This is a pure javascript calendar, no jQuery or other dependencies required.

Usage

Please make sure you have added the script tag added to the head of your page.

<script type="text/javascript" src="js/calendar.min.js"></script>

You should probably also make sure you include the calendar.css stylesheet, unless you are creating your own stylesheet.

<link rel="stylesheet" type="text/css" href="css/calendar.css">

It's really simple to implement a calendar by adding the HTML element to your page:

    <div id="calendar"></div>

Then define your calendar:

    Calendar(document.getElementById('calendar'))

By default, the calendar will use the current date as the calendar date, but you can specify a different date passing it through when you initialize.

    Calendar(document.getElementById('calendar'), {date:new Date()})

You can add the optional parameters by passing a JavaScript object. For example, by default, the calendar uses the browsers local time for Month and Day names. You can override this by passing in your own:

    Calendar(document.getElementById('calendar'), {date:new Date(), days:['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']})

Parameter options:

  • 'date' - The date of the calendar to be instantiated.
  • 'class_prefix' - The class prefix to be used for the calendar. Default is 'javascript-calendar'.
  • 'months' - Override the Month names i.e January, February, March, April, May, June, July, August, September, October, November, December.
  • 'days' - Override the day names i.e Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
  • 'events' - The formatted array of events.

The passed event array must be in the following format:

var events = [
    {start: '2025/04/01', end: '2025/04/07', summary: "Example Event", mask: true},
    {start: '2025/04/14', end: '2025/04/20', summary: "Example Event #2", mask: true},
    {start: '2025/05/05', end: '2025/05/15', summary: "Example Event #3", mask: true}
];

Each event must have a start date, end date, summary string and a mask boolean. The mask boolean should be true if you want to 'mask'(block off) event dates, or false.

Please make sure you include the calendar.css style sheet in the head of your page, unless you choose to use your own style declarations.

Requirements

None

License

Copyright (c) Benjamin Hall, ben@conobe.co.uk https://conobe.co.uk

Licensed under the MIT license

Donate?

If you find this project helpful or useful in anyway, please consider getting me a cup of coffee - It's really appreciated :)

Donate

As a self-employed tutor, I needed a way to streamline student assessments. Ben built a custom app that allows my students to complete quizzes and mock exams directly through my website. The automated notification system is a game-changer! It has made my workflow so much more efficient and has been a huge hit with my students. Ben’s work is top-tier.
Harrison K.