Potential Mistake in translate.js leads to performance issue
See original GitHub issueHello team,
why is here an addBack
??!
In some occasions this leads to document beeing included into the search, thus find("*")
matches every single element on the page:
Yes, this is followed by some filters, but still, why do one pass a container to look in, when afterwards whole page gets scanned anyway?
On my (quite strong) machine this leads to 360ms delay loading the devices.
Thanks and best regards
Thiemo
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
The 10 Most Common JavaScript Issues Developers Face
The common errors that developers make while coding in JavaScript include mistaken thinking about how the "this" keyword works, incorrect assumptions about ...
Read more >Javascript translations are loaded in the wrong order due to ...
The javascript translations file that enables translation of javascript strings is not loading, which may result in mixed languages on a page, ...
Read more >Huge Performance Issues - WordPress.org
The translated version is expected to work slower in the secondary language due to the nature of the plugin. We need to parse...
Read more >Getting Google Translate plugin Corrections and Suggestions ...
Removing the associated google-translate-customization -meta tag makes it possible to send in suggestions, but these suggestions does not show ...
Read more >Handling common JavaScript problems - MDN Web Docs
Let's get to work. The error is now being thrown at line 51. Click on line number 51 in the center panel to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Atleast on my machine switching the speed increased quite a lot:
360ms at the start and now 12ms
I guess I solved the puzzle:
Calls:
.addBack()
having 0 matchesfind("*")
and.addBack()
resulting in 286 matches, all being within the specified container (".j_rooms, .j_functions"
)So in my opinion, they not just wanted to find those containers, but also all elements within those containers. Keeping that in mind
.addBack()
is definitly necessary but has to be after the lookup for all elements within. So swapping lines 20 and 21 within translate.js results in following logic:I’ll prepare a PR later on