I am using the jQuery Date picker, but it is too heavy, the minified version of ui.datepicker.min.js is 44 KB. The images of datepicker have their own weight. The jQuery framework is 59 KB. And the total images on the page are around 80 KB. The total HTML of the page is around 70 KB and the CSS file size is around 72 KB. And much more, and all the things add up to 600 KB (0.6 MB).
Do you think the user will wait for 600 KB to be downloaded in the browser? It may take upto 8 - 10 secs. And I don't think that the user will wait for such a long time.
I want to keep my website lightweight. Is there any lightweight JavaScript date picker?
I just came across Pikaday, which looks good and is quite lightweight (around 11kb of JS, minified). Doesn't require jQuery either.
Here's a demo.
A screenshot of the picker:
(source: github.com)
Example using pikaday with timepicker and moment.js
<link rel="stylesheet" href="/pikaday/css/pikaday.css">
<script src="/pikaday/moment.js"></script>
<script src="/pikaday/pikaday.js"></script>
<script>
var timepicker = new Pikaday({
field: document.getElementById('datetimepicker'),
firstDay: 1,
minDate: new Date(2016, 0, 1),
maxDate: new Date(2100, 12, 31),
yearRange: [2016,2100],
showTime: true,
autoClose: false,
use24hour: false,
format: 'MMM Do YYYY, h:mm a'
});
</script>
github.com/owenmead/Pikaday
momentjs.com