Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Include JavaScript files to the document head with php

I'm creating a blog where I included header.php(Header, included in every page). Header contains a section where all the scripts (Scripts that will need in every pages) will be included.

header.php

<!DOCTYPE html>
  <html>
    <head>
      <!-- Scripts Section -->
      <script src="example01.js"></script>
      <script src="example02.js"></script>
      <title>Demo</title>
    </head>
    <body>
      <p>Blog</p>

But in a specific page, I've to include a specific script (file.js named).

index.php

<?php
  include('header.php');
  importjs('file.js'); /* Any Function To Import JavaScript*/
?>

If I include the JavaScript file here then it'll be included in body not the scripts section in the header. I don't know how to create that function. So please tell me how to create that function. create function in header.php and please first include the header before using function.

Thank You

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think, you should to write your line code like this example:

<?php int a; ?> 
<script type="text/javascript" src="file.js" /> 
<?php int b; ?>
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!