Minimized pages and processing for each requisition

10

If I want to minify an HTML page from PHP, will I be gaining or losing more?

More clearly: I want to keep formatting and practice for when editing the page, preserving the edentation. But I also worry about loading the page, since in development it is becoming heavier than I would like, so one solution is to minify and save some KBs by removing everything that is unnecessary for the user to download the page. Similarly with CSS and JS.

But since I wanted to do this with PHP (generate an output removing the garbage), I wanted to know if I would lose more time processing the page than if it had not minified and downloaded.

I understand that this depends on several factors, but I would like to consider large volumes of information (about 2MB not minified and 1.2MB minified), which is almost 60% difference in size. What are the factors that would allow page processing to slow down?

Are there any other options to make the page light?

    
asked by anonymous 10.06.2015 / 02:12

2 answers

3

You should Minify and Compress (note that they are different things) the HTML, CSS and JS of your site along with the images, however I work with Templates Dwoo I keep a version without the minification for work and another minified, are dynamic yet they remain minified since the template is minimized.

  • Minimize: It would remove whitespace (I also remove some useful quotes (when they are useless, eg when there is only one class in the class attribute)) (usually reduces by 15%).
  • Compressing: It would even compress, using Gzip, natively enabled in Nginx (usually reduces by 50%).
  • File Merge: Merge all .css and .js files into a single file (when distributing the page) including library files (be aware of interferences between variables), Rails Framework does this in a way almost transparent to users.

Tools: PageSpeed Insights

HTML Compressor (It has many advanced HTML compression options).

Compress My Code .

OBS: clarifying doubts: When I say "Compression" it would be compression of the file itself (type .rar .zip) where at the end of the process (Gzip compression and decompression) there is no modification of your contents of the file. already in the minification there is no compression of the .js and .css files (type .rar .zip), but a removal of useless content for the browser.

    
10.06.2015 / 14:54
3

Do you already have the site running on some public URL (or can you temporarily open to the public Internet for testing)? You can use PageSpeed Insights ; it will give you a more precise notion of where to earn performance.

My personal experience is that you have to first ensure that your server is compressing the files it sends; this will give you a much higher performance gain than indentation, at a much lower cost in electricity and phosphate.

    
10.06.2015 / 03:54