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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:36:35+00:00 2026-05-28T18:36:35+00:00

I have a website in which the total dynamic content is very small (say

  • 0

I have a website in which the total dynamic content is very small (say < 50k). The site itself is just a collection of 5-10 pages of mostly vanilla HTML. To separate the headers and such from the rest of the content, I’d normally use AJAX (so that AJAX queries grab the relevant HTML every time the user clicks on something, or beforehand).

In this case, since the dynamic content is so small, it seems unnecessary (and wasteful) to do 10 AJAX queries to load everything. The question is: “Is there a server-side way to load javascript variables with text from other files without web requests?”

The reason I ask is that it would be very easy for me to do this by hand, by just making a .js file with the variables loaded:

var page1 = "<p>Here's some web content!</p>"
var page2 = "<p>And some more!</p>"

Problem solved. Except that now my content is mixed up with my Javascript, and I have to worry about escaping quotes, and I’m in indentation hell, and so on. I could certainly do server-side scripting (in php or ruby or whatever), but that seems a little heavyweight for such a simple thing.

Is there a cleaner way this can be done server-side? I will take “no” for an answer, here, if that’s the best that can be done.

  • 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-28T18:36:35+00:00Added an answer on May 28, 2026 at 6:36 pm

    You can define a PHP extension file as javascript via <script type="text/javascript" src="myJavaScriptGlobals.php"></script>

    Have PHP dynamically pull all your data together, and output valid JavaScript.

    echo '
    var page1 = "'.str_replace('"','\"',$page1ContentFromFOPEN).'"; // escape double quotes
    ';
    

    This makes it so you don’t need to do any http requests after page load and achieving instant content load from assigned variables like page1.

    Updated to only strip double quotes

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

Sidebar

Related Questions

I have a website which uses PHP and HTML pages, I want to create
I have a website which allows secure (ssl) file uploads and download. The site
I have just started creating my first website, which is backed by a database
I have some website which requires a logon and shows sensitive information. The person
I have a website which uses the custom 404 error handling in PHP/Apache to
I have a website which uses TinyMCE textboxes for editing. It works fine except
I have a website which sells a product to the user (downloadable). I am
I have a website which fetches information from RSS feeds periodically (well, currently manually,
I have a website which works with PHP on the server side. Users access
I have a website which uses Spring Security. I have realized that when I

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.