npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaflet-defaulticon-compatibility

v0.1.2

Published

Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS.

Downloads

136,292

Readme

leaflet-defaulticon-compatibility

Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS. Demo with webpack (and without this plugin).

GitHub releases npm

Size: < 2kB minified

Note: here, "compatibility" does not refer to browser compatibility, but with build engines and frameworks that modify URL's in CSS, which often conflicts with Leaflet built-in Default Icon images automatic management. See issue Leaflet/Leaflet#4698 for more details.

Usage

$ npm install leaflet-defaulticon-compatibility --save

Load this plugin CSS and JS files after Leaflet CSS and JS. Then the Leaflet default icon should automatically work again, even if your build engine or framework modifies the URL's in CSS, typically:

For example for webpack with style-loader + css-loader + file-loader:

import 'leaflet/dist/leaflet.css';
import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css'; // Re-uses images from ~leaflet package
import * as L from 'leaflet';
import 'leaflet-defaulticon-compatibility';

CSS file

This plugin provides 2 similar CSS files:

  • leaflet-defaulticon-compatibility.css: use it by default.
  • leaflet-defaulticon-compatibility.webpack.css: alternative for webpack / bundlers that understand the ~leaflet syntax to navigate to other packages in node_modules. This avoids duplicating the images/marker-icon.png file from leaflet.css, hence saving some bytes, especially when the images is inlined as DataURI/base64 (even though with gzip compression this should not be an issue).

Warning: Data URI (base64) images performance

Some bundlers automatically replace url(path) in CSS by Data URI (aka base64-encoded) image (i.e. url(data:image/png;base64,SOME_DATA)). That is typically the case of webpack url-loader and Django pipeline.

If your map displays hundreds of Markers using this inlined image as icon, be aware that it will affect the browser performance much more quickly than using a normal URL file.

Fix: Firefox high contrast (colours override) option

This plugin also fixes an edge case in Firefox when a user has configured their browser to always override the websites colours.

When that option is set to "Always" in Firefox preferences, all background images are removed. Therefore Leaflet can no longer detect the default icon images path that was clued through CSS .leaflet-default-icon-path class background-image rule.

In that case, this plugin will try to use the cursor rule instead which is not affected by Firefox colours override option. Therefore the plugin CSS duplicates the images path in both background-image and cursor rules.

However, if you use this plugin to specify your own icon in CSS, make sure to still use background-image rule as the first mean to pass your images path, because Internet Explorer always interpretes URL's in cursor rule as absolute.

License

license

leaflet-defaulticon-compatibility is distributed under the BSD 2-clause "Simplified" License, like Leaflet.