Request for Autoptimize compatibility
-
Hi there,
I switched to Antispam Bee yesterday and it is an excellent plugin – thanks ??
The only issue I have is that I also run the Autoptimize plugin by @optimizingmatters. This has an option to aggregate inline Javascript. With this option enabled and Antispam Bee installed, the Autoptimize cache fills up very quickly.
The reason for this as I can see is that the Antispam Bee plugin inserts inline script into each page near the comment area, which seems to change on each post. The code to insert it is as follows (from line 1201 of antispam_bee.php)
$id_script = '<script type="text/javascript">document.getElementById("comment").setAttribute( "id", "a' . substr( esc_js( md5( time() ) ), 0, 31 ) . '" );document.getElementById("' . esc_js( self::get_secret_id_for_post( self::$_current_post_id ) ) . '").setAttribute( "id", "comment" );</script>';
Autoptimize recognises a script attribute, “data-noptimize”, which means the inline script won’t be inlined. So if line 1201 could be modified to:
$id_script = '<script data-noptimize type="text/javascript">document.getElementById("comment").setAttribute( "id", "a' . substr( esc_js( md5( time() ) ), 0, 31 ) . '" );document.getElementById("' . esc_js( self::get_secret_id_for_post( self::$_current_post_id ) ) . '").setAttribute( "id", "comment" );</script>';
This would definitely help. There’s also an option to exclude a script in Autoptimize by matching a pattern, but this script is fairly generic and doesn’t have a unique attribute I could use.
Thanks ??
- The topic ‘Request for Autoptimize compatibility’ is closed to new replies.