Here is the code to generate and download the .ics file for an event using jQuery.
var todayDate = new Date();
var msgData = todayDate.toISOString();
var startDate = e.start.toISOString();
var endDate = e.end.toISOString();
var icsMSG1 = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:https://www.google.com/\r\nBEGIN:VEVENT\r\nUID:https://www.google.com/\r\nDTSTAMP:" + msgData + "Z\r\nDTSTART:" + startDate + "\r\n";
var icsMSG2 = '';
if(endDate != '') {
icsMSG2 = "DTEND:" + endDate +"\r\n";
}
icsMSG3 = "SUMMARY:" + title + "\r\nEND:VEVENT\r\nEND:VCALENDAR";
icsMSG = icsMSG1 + icsMSG2 + icsMSG3;
$('.test-ics').click(function(){
window.open( "data:text/calendar;charset=utf8," + escape(icsMSG));
});
and, add this line in your html code
<div><a class="test-ics">Add to Calendar</a></div>
replace e.start with your event start date & time
replace e.end with your event end date & time
replace title with your event title