commenthol / date-holidays

worldwide holidays
https://commenthol.github.io/date-holidays/
Other
911 stars 236 forks source link

Can you please add any documentation on how to use this in a browser #338

Closed FrankW76 closed 2 years ago

FrankW76 commented 2 years ago

I created a small script which runs fine in npm (after an npm install)

var Holidays = require('date-holidays')
var hd = new Holidays()

var countries = hd.getCountries()
console.log(countries)
hd = new Holidays('NL')
var holidays = hd.getHolidays(2022, 'fr')
console.log(holidays)

But can you please provide some instructions on how to make this work in a browser? I looked at https://commenthol.github.io/date-holidays/ and at the index.js used. But I can't make anything out of it.

I tried using browserify on my script above but it gives some errors about import/export. I tried babelify on my script but that gives other errors.

I was hoping that I could just do a <script src='....date-holidays.js'>

in the head of my html file. And after this just being able to use the library (like just typing in the console of the browser "new Holidays()". But I can't find a js file to be loaded this way anywhere in this project.

Looking at the main page (browser chapter) I pressume it should be simple but I spend hours on this and not getting any step further.

commenthol commented 2 years ago

Please take a look at https://github.com/commenthol/date-holidays#cdn