add_action('wp_head','hook_javascript'); function hook_javascript() { $output="<script> alert('Page is loading...'); </script>"; echo $output; }