Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated DOM utilities and simplify marker SVG #11321

Merged
merged 4 commits into from
Dec 1, 2021
Merged

Conversation

mourner
Copy link
Member

@mourner mourner commented Dec 1, 2021

  • Remove DOM.setTransform(el, ...) in favor of el.style.transform = ....
  • Remove DOM.remove in favor of el.remove() (supported everywhere except IE11).
  • Remove DOM.addEventListener/DOM.removeEventListener in favor of el.addEventListener (options / passive listeners supported everywhere except IE11).
  • Introduce DOM.createSVG utility in place of DOM.createNS which we only used for SVG.
  • Overhaul default marker SVG generation code, removing redundant elements and simplifying code so that default markers are now more performant while looking slightly nicer — previously the shadow was approximated by 8 ellipses of varying opacity, now it's one with a gradient.
  • Consequently, reduce the gzipped bundle size by 688 bytes.

Marker before:

image

Marker after:

image

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • n/a write tests for all new functionality
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Improved default marker performance.</changelog>

@mourner mourner added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Dec 1, 2021
@mourner mourner requested a review from SnailBones December 1, 2021 20:23
Copy link
Contributor

@SnailBones SnailBones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good

@mourner mourner merged commit 941ba0f into main Dec 1, 2021
@mourner mourner deleted the cleanup-dom branch December 1, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants