I think you need to be careful to preserve the child index of the link tag relative to its siblings - otherwise the CSS cascade might change. If I'm understanding this code, it will always re-add the tag at the end of its parent, even if it wasn't at the end to begin with - it should re-add it at its original index.