For a faster future v2
Time for more optimization, the extension is slower than the Userscript due to some optimization being rolled back...
Done:
- Disabled YaMD5 as it is not used anymore.
- I just realized that I can't use the lazy load trick anymore due to
$is now defined onwindow... a.filteris now able to handle function names like_(:3 」∠ )_.- Payloads that requires replace are changed to templates.
- Generic payloads are going to be left as-is since carrying duplicate code isn't clean,
a.generic()only take 3 ms anyway. - According to my tests, making a no-loop version of
a.domCmpanda.domIncdoes not really change performance, just make development harder. - Replaced jQuery with domlib.
Note:
- Before optimization, the extension takes about 53 ms to execute.
- The Userscript takes about 10 ms to execute, bit Violentmonkey wrapper takes 30 ms (so 40 ms total).
- The extension currently takes about 25 ms to execute.
Looks like there isn't a way to squeeze execution time below 40 ms without replacing jQuery...
I made a replacement of jQuery, which is significantly lighter and is able to take advantage of latest Chromium's built-in functions. However, it can only do a fraction of what jQuery can, that is enough for now, I will expand it as needed. The initial execution time is down to about 25 ms (on the go-to test page https://blockadblock.com/ ) Other executions are asynchronous and are done as the document loads, 2 to 5 ms here and there, won't make a difference as the initial burst is what slows down page load.
Let me know if something broke, I did a few quick tests and it seems to work...
Let me know if something broke, I did a few quick tests and it seems to work...
This, for example https://github.com/jspenguin2017/uBlockProtector/blob/master/Extension%20Compiler/Extension/content/content-rules.js#L2293L2294L2295
^^
Instead of having three separate removals, why not just block it with exrapidleech.info###idnotice ?
@lain566 Eh... yea... Let me fix it...
@uBlock-user Can't, must leave one or it will trigger anti-adblock. And must remove and not hide.
@lain566 Updated, it is working correctly now. Pushing to store. 👍 👍
Now that jQuery is gone, will we still be able to do everything like we used to with jQuery or do we have limitations ?
Not just that, the new library behaves differently than jQuery. Why are you worrying about this? I can expand my library as needed.
Not worrying, but rather curious as you mentioned "it can only do a fraction of what jQuery can" which can be a dis-advantage depending on the situation.
Yea, it is missing most of the API, but it is trivial to add them. I don't want to add them now because I'm not using them. jQuery includes many workarounds to bypass bugs in old browsers, which is not needed for our case and just make things slow and bloated. jQuery runs tests when it is loading to see which workaround it needs to activate, there are hundreds of them, and none is needed for Chrome 59.
Seems to work pretty well, closing.