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 3229500
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:49:04+00:00 2026-05-17T16:49:04+00:00

I have a medium size legacy php application with almost no javascript integration. I’ve

  • 0

I have a medium size legacy php application with almost no javascript integration. I’ve recently been learning javascript (yes actually learning it) using Douglas Crockfords excellent book and taken YUI as my library of choice. I’ve tried out a few things and got a few things working but now I want to integrate the various components etc into my application properly, my question is how to go about doing this for ease of maintenance and code reuse.

Currently the application consists of

  • php pages
  • smarty templates (html templates with some special template markup) for each section of a page so multiple templates may be used for a single page.
  • single css file.

I have the following ideas about how to integrate my javascript into the pages.

  1. Write inline javascript in each smarty template with the code required for that section.
  2. Write a seperate .js file to go with each smarty template that is linked in and then a single inline script to run it.
  3. a seperate .js file for each php page which would have all the functionality required for the entire .php page. A small inline function would call whatever functions were required.
  4. Something I havent though of?

Does this make any sense? Does anyone have a good suggestion for this?

Update:

One extra bit of info is that its an internal application, so its not so important to restrict everything to a single file.

  • 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-17T16:49:05+00:00Added an answer on May 17, 2026 at 4:49 pm

    Two other options:

    1. A single JS file that contains all the JS for your entire site. Depending on your caching settings, you should be able to get the user to download just one file for the entire site and use a cached version for every other page.
    2. Divide your JS up according to function, rather than page, and include whatever functionality each page requires. E.g. one page may require tabs, form validation and animation, while another may only require tabs.

    Or you can have a hybrid of these: one JS file that contains the vast majority of your code and an extra file if needed for particular pages or templates.

    None of the approaches mentioned are wrong (though I’d skip the inline JS one as much as possible); which one is best will depend on your precise situation and your personal preferences.

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

Sidebar

Related Questions

I have a medium size Java file. Everytime I make a change to one
I have a string that is HTML encoded: '''<img class="size-medium wp-image-113"\ style="margin-left: 15px;" title="su1"\
I have a medium sized application that runs as a .net web-service which I
I have a medium sized application written in c++ using Qt. I wanted to
We have a medium sized .js file that we include in our web framework
I have two medium-sized web applications that I'm merging into one. They are both
I have a medium sized Django project, (running on AppEngine if it makes any
I've studied C programming in college some years ago and have developed some medium
I have a small to medium project that is in C++/CLI. I really hate
I have a comprehensive web application with the use of lots of nested tables.

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.