lucky-sideburn / kubeinvaders

Gamified Chaos Engineering Tool for Kubernetes
Apache License 2.0
1.02k stars 127 forks source link

JavaScript code optimization #82

Open lucky-sideburn opened 1 month ago

lucky-sideburn commented 1 month ago

Please review kubeinvaders.js and open me solvable issue to improve code

P0203K commented 1 month ago

Some solvable issues:

  1. Remove Duplicate Code for Repeated XMLHttpRequest Calls
  2. Reduce Use of Global Variables
  3. Replace var with const and let to avoid unintended bugs due to hoisting or scope.
  4. Use Caching for DOM Element Lookups. Repeated use of document.getElementById() and jQuery lookups is inefficient.
  5. Instead of constantly redrawing all aliens, only update and draw what has changed. Use a flag to track if positions or states have changed before redrawing.
lucky-sideburn commented 1 month ago

Dear @P0203K

Thank you! I would like to start from reducing global variables. I will let you know.