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

  • Home
  • SEARCH
  • 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

Hi guys my application parses text files where date values are stored in the
Hey guys, I'm using GWT for a data-driven web application, and I'm having issues
Hey guys I am trying to implement the twitter for posting the comments about
Hi guys I'm building a facility to be able to generate a csv file
First of all, I am new to the Silverlight + MVVM world. So I
Guys, Can you please tell me that ,I wants to learn Azure , by
Hei guys i have this JQuery Ajax call from my view and it looks
Hey guys im having a bit of a problem with my iPhone app where
Sorry, this is quite a special topic so this may not be of interest
I have alluded to this issue in my other question , but i think

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.