--- layout: v2 title: Download bodyclass: download-page --- ## Download Leaflet
Version Description
Leaflet 1.9.4 Stable version, released on May 18, 2023.
Leaflet 1.8.0 Previous stable version, released on April 18, 2022.
Leaflet 2.0-dev In-progress version, developed on the main branch.
[View Changelog](https://github.com/Leaflet/Leaflet/blob/main/CHANGELOG.md) Note that the main version can contain incompatible changes, so please read the changelog carefully when upgrading to it. ### Using a Hosted Version of Leaflet The latest stable Leaflet release is available on several CDNs. To start using it with an [importmap](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap), place the following in the `head` of your HTML code: ```html ``` A [**`importmap`**](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap) allows defining module specifiers (`import` paths) in the browser without relying on a bundler. It enables the use of named imports directly from a CDN or local files, making module resolution more flexible and readable. Then, in your script, import the needed Leaflet Classes as follows: ```js ``` #### Including Leaflet with a Global Scope The old (and no longer recommended) way to include Leaflet in your project without using modules is by relying on the global variable `L`. ```html ``` Note that the [`integrity` hashes](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) are included for security when using Leaflet from a CDN. Leaflet is available on the following free CDNs: [jsDelivr](https://www.jsdelivr.com/package/npm/leaflet?path=dist), [cdnjs](https://cdnjs.com/libraries/leaflet), [unpkg](https://unpkg.com/leaflet/dist/). _Disclaimer: These services are external to Leaflet; for questions or support, please contact them directly._ ### Using a Downloaded Version of Leaflet Inside the archives downloaded from the above links, you will see four things: - `leaflet.js` - This is the minified Leaflet JavaScript code. - `leaflet.js.map` - This is a source map file for `leaflet.js`, allowing browser developer tools to map minified code back to the original source for easier debugging. - `leaflet-src.js` - This is the readable, unminified Leaflet JavaScript, which is sometimes helpful for debugging. (integrity="{{site.integrity_hash_source}}") - `leaflet-src.js.map` - This is a source map file for `leaflet-src.js`, providing debugging support for the unminified version of Leaflet. - `leaflet.css` - This is the stylesheet for Leaflet. - `images` - This is a folder that contains images referenced by `leaflet.css`. It must be in the same directory as `leaflet.css`. Unzip the downloaded archive to your website's directory and add this to the `head` of your HTML code: ```html ``` Then, import Leaflet in your JavaScript file: ```js import {Map, TileLayer} from 'leaflet'; const map = new Map('map').setView([51.505, -0.09], 13); new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap' }).addTo(map); ``` ### Using a JavaScript Package Manager If you use the [`npm` package manager](https://www.npmjs.com/), you can fetch a local copy of Leaflet by running: ```sh npm install leaflet ``` Then, import Leaflet in your JavaScript file: ```js import {Map, TileLayer} from 'leaflet'; const map = new Map('map').setView([51.505, -0.09], 13); new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap' }).addTo(map); ``` You will find a copy of the Leaflet release files in `node_modules/leaflet/dist`. ### Leaflet Source Code These download packages above only contain the library itself. If you want to download the full source code, including unit tests, files for debugging, build scripts, etc., you can download it from the GitHub repository. ### Building Leaflet from the Source Leaflet's build system is powered by the [Node.js](http://nodejs.org) platform, which installs easily and works well across all major platforms. Here are the steps to set it up: 1. [Download and install Node](http://nodejs.org) 2. Run the following command in the command line: ```sh npm install ``` Now that you have everything installed, run `npm run build` inside the Leaflet directory. This will combine and compress the Leaflet source files, saving the build to the `dist` folder.