Code Monkey home page Code Monkey logo

Comments (2)

gorhill avatar gorhill commented on May 16, 2024

Idea: test only against the nodes which have not been tested yet, this means will need to keep the untested nodes around until they are tested. First untested node is document.body. Sounds very promising.

from ublock.

gorhill avatar gorhill commented on May 16, 2024

Testing only changed nodes didn't work too well. Actually, it worked well for the test site I used, quite heavy si.com, but it didn't work well with a lighter site, jshint.com, because a whole lots of nodes are created for this one, and I got the reverse result in this case. So I tried something else, which is to split the generic filters into two groups, the highly generics, and the lowly generics. The lowly generics are the one in the form (regex):

/^(([a-z]*)\[(alt|title)="([^"]+)"\])$/

For examples:

[title="Get Posts On Facebook Wall"]
a[alt="Follow Us on Twitter"]
a[title="Subscribe on FriendFeed"]
img[alt="Share on Twitter"]
img[title="Share at Google+"]

The highly generics are anything else than the above, for examples:

[class^="social_button_"]
a[href^="http://www.adxpansion.com"]
div[id^="div-gpt-ad-"]

A fast dictionary approach can be used for the lowly generics, and for the high generics, same approach as before is used. Nice side-effect aside the ~30% performance gain, less irrelevant rules are likely to be injected (not that this was an issue given the already low likelihood).

queryselector

Above is si.com, reloaded 8 times -- so divide overhead introduced by uBlock seen in the pic by 8 to get average added overhead for top culprit calls (for rather demanding si.com). So before changes, overhead per-page load was 92ms, after it was less than 60ms (for front page of quite demanding si.com that is).

from ublock.

Related Issues (20)

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.