Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 912457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:23:00+00:00 2026-05-15T17:23:00+00:00

HI guys, my application uses a lot of different javascript files. SO I tried

  • 0

HI guys, my application uses a lot of different javascript files. SO I tried to be quick about it and accomodate all the files in one single file. This I did by creating a single php with the following code:

<?php
header('Content-type: text/javascript');


$js = array( ....   ); // all files to include

$js = array_unique($js);

foreach($js as $oneJs)
    require_once('scripts/'.$oneJs);

And including a reference to this file where I need to include the javascript as:

<script type="text/javascript" src="includes/js.php"></script>

I’m using prototype js here and the scriptaculous libraries – the problem is that I’m getting loads of errors and now half my javascritp wont run. Especially now I’m getting the $ is not defined error. I’ve included prototype in the list but I’m still getting this error – help please!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:23:01+00:00Added an answer on May 15, 2026 at 5:23 pm

    You need to be careful of two things when doing this.

    1. Make sure the loading order is correct. If you have script files that use jQuery, jQuery needs to be loaded first. The $ is not defined error sounds like jQuery is loaded too late.

      What I sometimes do for this is add numbers to the names (1_jquery.js, 2_dialog.js….) and then do a sort() on the array.

      You could also consider using an array to specify the order of the most important javascript includes, and load the rest in arbitrary order.

    2. Make sure there are no "misunderstood" statements because of missing ";"s at the end of each script file that become glued together. It’s a good practice to echo a standalone ";" in between each included file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am debugging an application that uses an XML file to store data as
Let say i have one asp.net application that is having some page that uses
Hi guys im trying to create a application that uses a socket connection i
Ok guys I'm creating an application in CodeIgniter that utilizes the Facebook SDK, both
Hai Guys, My application deals scheduled mail concept (i.e) every morning 6.00 am my
Hi guys I've integrated roundcube mail albeit pretty bluntly in my application i.e I
Guys, I have a basic WPF application. Contains App.xaml as always and a Mainwindow.xaml.
Hai guys, I want to send scheduled mail every morning from my application and
Ok guys so a little background... I'm writing a small application that will assign
This will be simple for you guys: var uri = new Uri(pack://application:,,,/LiftExperiment;component/pics/outside/elevator.jpg); imageBitmap =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.