Alright, I wrote a small proof of concept that demonstrates just how much of a difference hiding the frame before you reposition it makes, even if it makes no visible difference in-game.
Lua Code:
local Nameplates, PreviousWorldChildren = {}, 0 -- Table to hold our list of detected nameplates
WorldFrame:HookScript('OnUpdate', function(self)
local currentWorldChildren = self:GetNumChildren()
if currentWorldChildren ~= PreviousWorldChildren then PreviousWorldChildren = currentWorldChildren
for _, plate in pairs({self:GetChildren()}) do
if not Nameplates[plate] then -- Check if it's already been seen
local name = plate:GetName()
if name and strmatch(name, '^NamePlate%d+$') then -- Test that it's a nameplate
Nameplates[plate] = CreateFrame('frame', nil, WorldFrame) -- Record our new frame
for i = 1, 500 do -- Make a bunch of regions for a stress test
local fs = Nameplates[plate]:CreateFontString(nil, nil, 'GameFontNormalHuge')
fs:SetText('LAG')
fs:SetPoint('CENTER', math.random(-50,50), math.random(-12,12)) -- This is just to make it look more interesting
end
end
end
end
end
for plate, f in pairs(Nameplates) do -- Iterate over existing nameplates every frame
if plate:IsShown() then -- Check visibility
f:Hide() -- Try commenting this out and see what happens to your frame rate
f:SetSize(plate:GetSize()) -- This isn't necessary to call every update but it simplifies the example
f:SetPoint('CENTER', WorldFrame, 'BOTTOMLEFT', plate:GetCenter()) -- Position our frame relative to the nameplate
f:Show()
else -- Hide if nameplate is hidden
f:Hide()
end
end
end)
You can forget about repositioning the frame OnUpdate without hiding it first, it doesn't seem to make as much of a difference as I thought. On the other hand, this trick seems to make a huge difference.
The only downside is it lags one frame behind the default nameplate, but maybe there's a way to overcome that.
There are 2000 font strings per nameplate in this screenshot, and while it has dropped my frame rate down to around 15 fps I can still smoothly rotate the camera and run around without any issues. Attaching them directly to the nameplate completely freezes the game in this same test.