Code for my portfolio website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
776 B

  1. const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
  2. if (vw <= 1000 && vw >= 500) {
  3. lazy = document.querySelectorAll('[id="lazy-tablet"]')
  4. eager = document.querySelectorAll('[id="eager-tablet"]')
  5. for (var i = 0; i < lazy.length; i++) {
  6. lazy[i].setAttribute("loading", "lazy");
  7. }
  8. for (var i = 0; i < eager.length; i++) {
  9. eager[i].setAttribute("loading", "eager");
  10. }
  11. }
  12. if (vw <= 500) {
  13. lazy = document.querySelectorAll("img.lazy-mobile")
  14. eager = document.querySelectorAll("img.eager-mobile")
  15. for (var i = 0; i < lazy.length; i++) {
  16. lazy[i].setAttribute("loading", "lazy");
  17. }
  18. for (var i = 0; i < eager.length; i++) {
  19. eager[i].setAttribute("loading", "eager");
  20. }
  21. }