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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:49:29+00:00 2026-06-15T00:49:29+00:00

I have a site with the files all being php files, on the server

  • 0

I have a site with the files all being php files, on the server we also have htaccess doing rewrites for friendly urls, i.e. /about

We already have minification by PHP for JS and CSS, however due to the fact the HTML is on the actual page is there a way of minifying the html after the php has added in the dynamic bits of the page but before the server sends it back to the client?

I have tried implementing minify, however the callback function breaks the page with no errors.

  • 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-06-15T00:49:30+00:00Added an answer on June 15, 2026 at 12:49 am

    If we’re talking about dynamically minifying everything on the fly, I would council you to be cautious about seeing this as an optimisation.

    Yes, there may be a significant bandwidth saving to be had. And yes, it is possible that your users may get a performance boost from the smaller downloads.

    But, if you’re minifying your files on the fly using PHP (which is what it sounds like you’re doing), it is also possible that you may actually be slowing things down for the end user.

    Minification is best done on static files. Minify them once, save them, and serve the minified file to the browser without any further processing when the file is requested. Doing it in PHP every time a file requested can be a significant performance overhead which could easily counteract the gains from the smaller download size.

    Minifying HTML is usually less effective than Javascript. The best way to ‘minify’ your PHP-generated HTML is to cut out the unnecessary white space from your HTML template files. This is usually a pretty easy task, and doesn’t need a dedicated minifier tool — simplest way to do it is just to remove all indentation from the file. White space is relevant in HTML, so you can’t just get rid of it all, but losing the indentation should deal with most of it, while conveniently still leaving the file reasonable readable.

    So my advice is to minify your files statically if possible. But if you must do it on the fly, don’t use PHP for the job. Use a dedicated server plug in, such as Google’s mod_pagespeed. This plugin will minify the files for you when they’re requested (at much higher speed than PHP could do it), and also takes care of caching the minified version, to minimise the performance impact.

    Hope that helps.

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

Sidebar

Related Questions

I have a site that allows download or streaming of mp3 files. All the
I have a site with this simple structure: \public_html {files}.php \files \es For the
I have about 15 .RPT files on my .NET 2.0 site, and I recently
Let's say I have about 10 css files on my site. I wanted to
I have this line in my htaccess file: RewriteRule (.*) index.php This catches all
I have a site that has a /sites/default/files/ directory where user content is typically
I have a site that allows people to upload large video files in various
I have a simple site which allows users to upload files (among other things
I have a web site project with a lot of files, it has become
I have 2 css files in my page: Site.css jquery-ui.css Site.css is listed BELOW

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.