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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:54:08+00:00 2026-05-26T13:54:08+00:00

Background: I’m working on a single page web app that loads everything through AJAX

  • 0

Background: I’m working on a single page web app that loads everything through AJAX and so started learning php a few days ago. I immediately thought of putting everything (html, css, javascript) in php files so that there is only one html file and one sprite request. For instance, external javascript could be stored in:

main.js.php (adding the .js for organizational purposes only) which would look like:

<script>
 ...
</script>

or

<style>
 ...
</style>

Question: Would storing everything in php be a bad idea? I have OCD and like to have related functions in separate files (and actually, folders too), so let’s just say my project uses 100+ includes. These only get loaded exactly once, when the user visits (AJAX site). I want to reduce the number of Http Requests to just 1 html and 1 sprite (my app uses a custom font for images actually). My app will also be ran on mobile devices (using a different design, using far fewer includes but a similar method).

Research: Here’s what I know:

  • You can have Apache handle js/css as php, but is not something I’m interested in (dangerous) – link
  • This site gave me the idea, although I don’t quite understand it – 3 Ways to Compress CSS
  • Caching with something like APC (not sure how it works, but out of the scope of this question) would improve php speeds (?)
  • 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-26T13:54:09+00:00Added an answer on May 26, 2026 at 1:54 pm

    some points to consider:

    1. code – text ratio:

    your content pages are read by google. when google is ranking you pages, one of the parameter is the ratio of code versus the textual content. if you put your css/js code together with the content, you lower the ratio. (btw, one of the arguments for using divs instead of tables is that tables normally will take more html code and lower the ratio).

    EDIT: this is a theory and not really known fact. it’s important that the html code will be syntactically correct, so it will be easier to parse by search engine parsers. some say that google ignores the content that comes after the first 100kb, so it’s also something to consider.

    2. nginX

    i have nginx installed with apache as a reversed proxy to handle php.

    nginx is an http server, that knows how to handle static pages. apache’s design is thread per client, while nginx uses the reactor pattern, meaning – nginx can handle much more traffic than apache as a web server (about 50 times the number of requests).

    the drawback is that nginx doesn’t handle the php requests, and for that the apache is installed too – nginx will send all the php calls to the apache, so it will handle them and return the response back to nginx, and back to the client.

    if in that setup (which is quite common) you will put css/js files under javascript, you will lose the advantage of the nginx, which instead of handling the static js/css files on its own, it will send them to the apache as it’ll address them as php pages.

    3. cache

    caching files is one of the most common mechanisms to improve your website performance, while reducing traffic. if you mix static content with dynamic content, you will lose the advantage you get from caching static files.

    when working in web environment, it’s best (as a habbit) to keep as much static content as you can separated from dynamic content. this will give you the best results when caching static data.

    of course, there are no rules for what should and what shouldn’t. i have many dynamic js contents, but the main functions are normally extracted to static files.

    4. CSS sprites

    css sprites (as @Muu mentioned) are a great improvement to performance and should definitely be adopted.

    another recommendation more specific to your case – if you want your content indexed properly – since you mentioned that most data will be loaded using ajax, i’d recommend to have it present also without ajax. for example: http://www.domain.com/ will have a link to #contact, that will show the form (loaded using ajax). you should also have http://www.domain.com/contact for indexing. also make sure that if a user enters http://www.domain.com/#contact – he will be redirected to the contact page (or content will be loaded dynamically).

    use browsers’ web dev tools to see what requests are being made and see where you can lower the number of requests, and also pay attention to file sizes, see which files are cached and which are requested by the server. define cache attributes in you server config and htaccess.

    hope that helps 😉

    PS: another tip – if you get water spilled all over your keyboard – don’t try to dry it with a hair dryer – it could melt down your keys…

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

Sidebar

Related Questions

Background I have a web app that will create an image from user input.
Background Use Ajax to fire an event to the web server when a list
Background: I'm working through the Programming Collective Intelligence book by Toby Segaran; specifically the
Background : I'm working on a management page for musicians. Lets say the user
Background: I have a little video playing app with a UI inspired by the
Background: At my company we are developing a bunch applications that are using the
BACKGROUND: I'm writing a single level cache simulator in C for a homework assignment,
Background: I have a website that has been built with ASP.NET 2.0 and is
Background: I have created sample windows application for learning to implement localization. My each
Background I'm designing a Rails app to record research data. Most of it can

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.