diff --git a/docs/cdn.md b/docs/cdn.md new file mode 100644 index 0000000000..30cd142b74 --- /dev/null +++ b/docs/cdn.md @@ -0,0 +1,111 @@ +# CDN + +Starting with v3.6.0, the CDN versions of date-fns are available on [jsDelivr](https://www.jsdelivr.com/package/npm/date-fns) and other CDNs. They expose the date-fns functionality via the `window.dateFns` global variable. + +Unlike the npm package, the CDN is transpiled to be compatible with IE11, so it supports a wide variety of legacy browsers and environments. + +```html + + + + +``` + +The CDN versions are available for the main module, all & individual locales, and the FP submodule. + +They come in two flavors: `cdn.js` and `cdn.min.js`. The latter is minified and should be used in production. The former is useful for debugging and development. + +Keep in mind that using the CDN versions in production is suboptimal because they bundle all the date-fns functionality you will never use. It's much better to use the npm package and a tree-shaking-enabled bundler like webpack or Rollup. However, the CDN versions are helpful for quick prototyping, small projects, educational purposes, or working in a legacy environment. + +## Main module + +The main module with all functions bundled: + +``` +https://cdn.jsdelivr.net/npm/date-fns@VERSION/cdn.js +https://cdn.jsdelivr.net/npm/date-fns@VERSION/cdn.min.js +``` + +You can access it via the `dateFns` global variable: + +```html + + +``` + +## The FP submodule + +The FP submodule with all functions bundled: + +``` +https://cdn.jsdelivr.net/npm/date-fns@VERSION/fp/cdn.js +https://cdn.jsdelivr.net/npm/date-fns@VERSION/fp/cdn.min.js +``` + +You can access it via the `dateFns.fp` global variable: + +```html + + +``` + +## Locales + +All locales bundled: + +``` +https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/cdn.js +https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/cdn.min.js +``` + +You can access them via the `dateFns.locale` global variable: + +```html + + + +``` + +The locales are also available as individual files. + +``` +https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/LOCALE/cdn.js +https://cdn.jsdelivr.net/npm/date-fns@VERSION/locale/LOCALE/cdn.min.js +``` + +You can access them via the `dateFns.locale.LOCALE` global variable: + +```html + + + +``` diff --git a/docs/config.js b/docs/config.js index 804e2d7a3e..400d5d73e6 100644 --- a/docs/config.js +++ b/docs/config.js @@ -84,6 +84,14 @@ module.exports.config = { summary: "Time zone functions", path: "timeZones.md", }, + { + type: "markdown", + slug: "CDN", + category: "General", + title: "CDN", + summary: "CDN version of date-fns", + path: "cdn.md", + }, { type: "markdown", slug: "webpack",