Does hook have an effect on increasing the page load?

I have a personal website which uses WordPress.
for same changes on the theme, I can add manually codes on single.php.
Or I can write a hook for it.
for example, I want to add content on a specific single.php line.

// I made a action
function after_p(){

and then put it on single.php

             <?php after_p();?>

then I add some line and PHP files with add action on function.php

// Download Box
if (!function_exists('downloadbox')) :
        function downloadbox()
            if (function_exists('get_field'){
 add_action( 'after_p', 'tc_downloadbox' );

// adv
if (!function_exists('my_adv')) :
        function my_adv()
            echo '<div id="java-script-advs"></div>';
add_action( 'after_p', 'my_adv' );

As you guess I am a beginner I have a doubt this way is current?
I mean does use the unnecessary hook have effects on page loading?
because on my case I can simply add include('downloadbox.php') on single.php(on the line what I want). at the same for echo '<div id="java-script-advs"></div>';

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

The cost of those hooks themselves is negligble and statistically insignificant. It would take great effort to measure such a change in performance, and would not take up more than a millionth of the total runtime. Unused hooks are not a performance concern.

The real concern here is that unnecessary complexity has been added that will show in the future as technical debt. I also notice you’ve wrapped all your functions in {} then again in a function exists check, both of which aren’t necessary

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply