Custom plugin init action causing general slowness

If you want your function to fire only once, you can use other hooks.

wp_head might be useful in your situation since it is fired before the rest of the template is rendered.

template_redirect is also fired before rendering the template.

If the sequence doesn’t matter to you, you can fire it at last using wp_footer or get_footer hook.