Question

I have a question. So i found this article by David Walsh - Prepend and Append Files with .htaccess. David shows how to prepend some file usuing .htaccess. I would like to know is there any option to prepend some javascript file into specify of page HTML code, f.e. in a head or just in the bottom of body? Thx for info.

Was it helpful?

Solution

Step 1: Add this in your DOCUMENT_ROOT/.htaccess file:

# Append file to bottom of page
php_value auto_append_file "includes/footer.php"

Step 2: Create DOCUMENT_ROOT/includes/footer.php with this content

<script>
    document.writeln('Its from javascript in footer');
    // put any JS code here
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top