inefficient JS calls to marc.field()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
New
|
Undecided
|
Unassigned |
Bug Description
I ran a JS profiler on the bib record view and found marc.field() is called thousands of times in the bib record view.
The number of calls increases with the number of MARC fields and subfields.
Part of the reason for this is marcedit.js, which is called in the background of the record view, even if the MARC editor is not being loaded.
Within marcedit.js, record.
https:/
This might not be so bad, except for the fact that marc.subfield calls marc.field, which in turn does a filter on the array of marc fields. Thus for each field, it (multiple times) has to scan each other field in the MARC record, all just to get the ID.
A sample record I tested with here:
https:/
This record calls marc.field() 105 times to get the 006, 105 times to get the 008, and 1348 times to get the 901. In total 1559 times. And with the .filter() calls, it means each MARC field was touched 38,775 times. This increases the longer the MARC record.
I'm not sure the solution, but I'd suggest three possible things:
1. cleaning up marcedit.js so it doesn't make so many calls like this in those templates. Again, in some cases this is just generating an HTML id which I don't think is ever referenced again. Or maybe the ID can be injected elsewhere
2. It might also be worthwhile to add a hash (by tag) to marcrecord.js to speed up those calls (although it would need to be updated every time the record is loaded or changes so this could slow things down in other ways)
3. It might be better if marcedit.js wasn't called until that tab is actually accessed. a lot of folks working in libraries never touch the marc editor
tags: | added: cleanup |