Support » Plugin: Autoptimize » Javascript Comments

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Frank Goossens

    (@futtta)

    it is undoubtedly possible: hooking into autoptimize_js_after_minify will give you the autoptimized JS before it is cached, so you can alter it to your liking.

    the problem is that these “important comments” contain license information which is not supposed to be stripped, legally (except if you have a place in your site where you list all js/ css components used of which you stripped the license information. taken that and the minimal gains into account, I generally advice against it 🙂

    frank

    Hi Frank,
    thx:)
    Can you give me an example for the helper file and the hook?

    Plugin Author Frank Goossens

    (@futtta)

    something like this:

    add_filter('autoptimize_js_after_minify','harry_removes_licences',10,1);
    function harry_removes_licences($jsIn) {
         $jsOut=magic-code-to-remove-comments($jsIn);
         return $jsOut;
    }

    the magic-code-to-remove-comments is where you would perform your magic 😉

    frank

    Hi Frank,
    thx a lot, it’s working;)

    Plugin Author Frank Goossens

    (@futtta)

    do share your magic (code) Harry, others might want to join in on the fun as well! 😉

    of course;)

    add_filter('autoptimize_js_after_minify','ao_override_js_after_minify',10,1);
    function ao_override_js_after_minify($jsIn) {
       $tag1 = '\/\*!'; //Suchterm Beginn - searchterm begin
       $tag2 = '\*\/'; //Suchterm Ende - searchterm end
       $jsOut = preg_replace("#".$tag1.".*".$tag2."#Uis", "", $jsIn);
    	return $jsOut;
    	}
    Plugin Author Frank Goossens

    (@futtta)

    great! you could even capture the content between tag1 & tag2 and write that to a “licences_used.txt”-file and be compliant and everything 🙂

    this would be a nice feature in your next version;)

    Ramanan

    (@superpoincare)

    Frank,

    I think the issue is not the important comments. It’s some bug in pagespeed and dynamic gzipping.

    If I load jquery from code.jquery.com, pagespeed doesn’t complain.

    So what’s happening is that dynamic gzipping compresses at level 4 or something and the difference between filesizes between this and level 9 is high.

    Google then probably does its own minifying and compares the ungzipped files and reports that the file can be shortened when in fact it should be saying that gzipping should happen at level 9.

    Plugin Author Frank Goossens

    (@futtta)

    interesting Ramanan 🙂

    alain2

    (@alain2)

    Hi

    While there’s a difference it isn’t that big 😉

    A 726KB css file did:
    gzip -4 to 126KB
    gzip -6 to 116KB
    gzip -9 to 115KB.

    The current default zlib (as of 2013) and thus Apache is -6.

    Plugin Author Frank Goossens

    (@futtta)

    thanks for clarifying alain2!

    alain2

    (@alain2)

    Just tested it on jquery.js itself. Going from compression 6 to 9 gave me a file reduction of 56 bytes.

    Ramanan

    (@superpoincare)

    I think it depends on the server @alain2

    Mine shows jquery in the range 34-39KB.

    Anyway my point was slightly different. I think a lot of people here get a score of 99 and want to get 100. Feel incomplete by not having 100/100 in Google Pagespeed. This can be avoided by compressing at level 9 not by worrying about comments (although removing comments may give a score of 100, but it’s not necessary that comments be removed to achieve 100/100).

    alain2

    (@alain2)

    Well if getting a 100/100 score is the goal….

    Pagespeed should be considered as suggestions.

    On a hand coded website pagespeed states that a 465 byte css response is blocking. But, it doesn’t state that it would be far better to aggregate the (only) two very small CSS files.

    BTW more than half of the webpagetest time is the DNS and https init.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Javascript Comments’ is closed to new replies.