0

Finding myself wondering which method of accomplishing a task is better and how to test (for "betterness").

better = lighter, faster, less expensive (page load-wise).

Task: close an open menu when the user clicks outside the menu.

Option 1: add a dependency to the project. Probably would go with this https://www.npmjs.com/package/vue-click-outside

Option 2: custom solution. Basically copy @MadisonTrash's solution here Detect click outside element

person13
  • 141
  • 9

1 Answers1

0

This is a highly opinionated question, but in my opinion, if the functionality you want to add is pretty simple, it would be better to add it to your solution.

The main problem that I have on always depending on external libraries (specially npm ones) is the potential issues that they might bring, e.g.:

https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/

https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5

So I would recommend keeping your libraries at minimum and use only the essential and from known/mature ones.

Wayrex
  • 2,027
  • 1
  • 14
  • 25
  • Yikes! Yeah I read an article about npm security audits. Still not 100% sure of how to address those audit concerns once their identified though. https://docs.npmjs.com/getting-started/running-a-security-audit?utm_campaign=2018-05-09%20nsp%20audit%20announcement – person13 Jun 13 '18 at 19:46
  • Well that sounds like an interesting question, but far away from the original one.. :) The idea would be to add it as an issue on the library repo, and (if you can) propose the solution to it. – Wayrex Jun 13 '18 at 20:14