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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:22:24+00:00 2026-05-17T22:22:24+00:00

Minimizing html is the only section on Google’s Page Speed where there is still

  • 0

Minimizing html is the only section on Google’s Page Speed where there is still room for improvement.

My site is all dynamic and the HTML is already Deflated so there is no reason to put any more pressure on the server (I don’t want to minimize pages real time before sending).

What I could do was to minimize the template files. My templates files are a mix of PHP and HTML so I’ve come up with some code that I think is pretty safe but would like to be community revised.

// this will loop trough all template files
// php is cleaned first so that line-comments will not interfere with the regex
$original = file_get_contents($dir.'/'.$file);
$php_clean = php_strip_whitespace($dir.'/'.$file);
$minimized = preg_replace('/\s+/', ' ', $php_clean);

This will make my template files as a single very long file alternated with some places where DB content is inserted. Google’s homepage source looks more or less like what I get so I wonder if they follow a similar approach.

Question 1: Do you antecipate potencial problems?
Question 2: Is there anyway better (more efficient to do this)?

And please remember that I’m not trying to validate HTML as the templates are not valid HTML (header and footer are includes, for example).

Edit: Do take into consideration that the template files will be minimized on deploy. As CSS and Javascript files are minimized and compressed using YUI Compressure and Closure, the template files would be minimized like-wise, on deploy. Not on client-request.

Thank you.

  • 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-17T22:22:25+00:00Added an answer on May 17, 2026 at 10:22 pm

    I’ve been running tests on all my sites for a couple of weeks and I can say that this method is pretty consistent. It will only affect template content, so there is little risk of messing up with unknown <pre> or similar.

    It is run before deploy so there is no impact on server – actually there should be a little speed up as the file becomes smaller.

    Do remember that all content that comes from the database will not suffer any influence as, like said before, this runs before deploy and on template files only.

    The method seams solid enough to pass it into production.

    If anything goes wrong I’ll post it here.

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

Sidebar

Related Questions

What're the best practices for CSS/HTML minimizing? I'm looking for server side tools to
I have these webapplications build in old style HTML, including [framesets] to speed up
I'm wondering if there is anything like Django's HTML templating system, for for CSS..
I am trying to get better about minimizing any unnecessary markup and using optimal
Recently I've been trying to save on render time by minimizing the amount of
YUI Compressor was the consensus best tool for minimizing, but Closure seems like it
I didn't manage to find any functionalities for minimizing/maximizing programatically. I want to minimize
I have been reading about css and js compression and minimizing. In particular that
Can any body give me a a introduction of how to program efficiently minimizing
I'm trying to get my head around the idea of testing functionality and minimizing

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.