Giter VIP home page Giter VIP logo

laerhsif-essay's Introduction

laerhsif-essay's People

Contributors

realfish avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xiamuguizhi

laerhsif-essay's Issues

GTP4 优化建议,感觉可以,斗胆发个issues

  1. 在代码中频繁地使用getImageData方法来读取上下文的像素数据,设置willReadFrequently属性为true可以提高性能。这是因为当你告诉浏览器你会频繁地读取像素数据时,浏览器可以采取一些优化措施。

  2. 在 a 函数中将 canvas 元素添加到了 DOM 中,然后在 c 函数中将其移除。这些操作可能会导致强制回流,因为它们修改了 DOM 的结构。你可以尝试将这些操作放在一个 requestAnimationFramesetTimeout 调用中,以减少回流次数。

    function a(e, t) {
        var n = $.create("canvas"),
          r;
      
        requestAnimationFrame(function() {
          (n.width = "50"),
          (n.height = "20"),
          (n.style.display = "none"),
          P.appendChild(n),
          ((r = n.getContext("2d", { willReadFrequently: true })).textBaseline =
            "top"),
          (r.font = "15px " + t + ", sans-serif"),
          (r.fillStyle = "black"),
          (r.strokeStyle = "black"),
          r.fillText(e, 0, 0);
        });
      
        return {
          node: n,
          context: r,
          remove: function () {
            requestAnimationFrame(function() {
              $.remove(n, P);
            });
          },
        };
      }
      

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.