Minify HTML output of Mergescript()

Topics: Developer Forum
Oct 22, 2013 at 12:46 AM
Edited Oct 22, 2013 at 3:43 AM
While debugging avfp generated HTML file in chrome, we may see a number of blank lines in HTML source file. These blank lines are the residue, after FoxPro code, within <% %> is evaluated and removed from the final HTML output file by the ActiveVFP.mergescript() function.

It may therefore be possible to minify this HTML file by running the following just before the final string is returned from this function.
*-------+ Remove empty lines and minify the HTML file.
If !EMPTY(lcStr)
 Local laComArray(1), lnCount, lcCompStr
 lcCompStr = ""
 For lnCount = 1 to ALEN(laComArray,1)
   *----+ Development version
   lcCompStr = lcCompStr+IIF(EMPTY(lcCompStr),"",CHR(13)+CHR(10))+ALLTRIM(laComArray[lnCount])
   *-------+ Comment out the above line and uncomment the following for production version      
   *lcCompStr = lcCompStr+CHRTRAN(ALLTRIM(laComArray[lnCount]),CHR(9),"")
 lcStr = lcCompStr

This does require extra processing, and you may not see any benefit in local machines but when client is on remote machine, this can make a lot of difference.

I have this in two flavours, the development version is good for debugging, however, production version gives the best minification.

One of my AVFP generated HTML file, gets compressed by 28% resulting is noticeable improvement in page loading. Normally, it should be 5% to 15% compression.