500 error when inlinecss and js is enabled
-
Hi, Frank its been a while I hope everything is good, well this issue I think I posted about it but long time ago but I have new info / approach : even using the filter to disable in a specific template (after it is enabled in global AO settings) it is returning the 500 error in the console though the page loads fine. This is the filter and code I’m using
function disable_autoptimize_inline_on() {
if ( is_page_template( 'single_actividades.php' ) ) {
add_filter( 'autoptimize_html_minify_inline_js_css', '__return_false' );
}
}I tried on localhost on my site setup to verify the filter actually worked and it did (had some code snippets that if I comment the above function/filter it does indeed minify them) and no errors then.
So thats what weird is that I was expecting that just by using the filter which excludes it from minify those pages (single pages) it would prevent the error from happening but it didn’t. And I think this error is important for SEO, while having the preference enabled is great for speed.
Also what I can do in order to further debug is replicate an activity single page with password in order to prevent it from being included in the loop for the live pages, and then modifying the filter to use the ID of the page.
Kind Regards
-
This topic was modified 2 months ago by
snippet24.
-
This topic was modified 2 months ago by
-
So if I understand correctly, this does work when using the ID of the page, so the problem is with how you check the template?
No, thats not it I’m afraid, I will explain: 1. the last paragraph is only an idea for testing debugging without affecting the actual pages in use of the site 2. the code with the template works; tested in another site 3. so the point is even when the filter is active for all the pages that use the template single_actividades.php well even there i still get the error 500 for those
ah, so you get a server error (HTP 50x), but the HTML does get returned and the inline CSS/ JS in that HTML is indeed not minified?
Yep thats it
in that case the problem is likely not (just) the inline JS/ CSS, but also one (or more) of the referenced CSS or JS files :-/
try if disabling JS optimization or CSS optimization helps, based on that we can add another filter to disable that?
Thank you, indeed disabling js optimization while using the inline pref enabled with the filter prevents the error.
I’m not sure how to use the filter autoptimize_filter_js_exclude to use in a specific template, unless there’s another filter?
-
This reply was modified 2 months ago by
snippet24.
OK so in the code snippet you already have, add a line to echo
true
to theautoptimize_filter_js_noptimize
filter to disable JS optimization on that pages that use that template.Like this?
function disable_autoptimize_inline_on() {
if ( is_page_template( 'single_actividades.php' ) ) {
add_filter( 'autoptimize_html_minify_inline_js_css', '__return_false' );
add_filter( 'autoptimize_filter_js_noptimize', '__return_true' );
}}btw in case is useful: exmple page with the error: https://www.otzerling.com/sesion-de-meditacion-guiada-en-centro-de-educacion-continua-uach/
indeed, that should disable JS optimization for that template.
so what error is logged in the PHP errorlog when optimize JS is active on those pages?
yeah, but that what you see in the browser, but on your server there should be a PHP errorlog file and in there a more detailed error would be logged, maybe have a look around in that file for pointers to where the problem occurs?
Ah sorry I fast read :/ sure here it is:
2025-03-08 18:41:17.106380 [NOTICE] [3454449] [T0] [127.0.0.1:33152#APVH_otzerling.com:443] [STDERR] PHP Fatal error: Uncaught JSMin_UnterminatedStringException: JSMin: Unterminated String at byte 367: "Hola te invitamos cordialmente a nuestras actividades de Agosto en Avda Amun..tegui 385 en La Serena los d..as s..bados desde las 10 am va a haber un pend..n o banderas budistas in /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php:212\nStack trace:\n#0 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(150): JSMin->action()\n#1 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(84): JSMin->min()\n#2 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(257): JSMin::minify()\n#3 [internal function]: AO_Minify_HTML->_removeScriptCB()\n#4 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(108): preg_replace_callback()\n#5 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(47): AO_Minify_HTML->process()\n#6 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/autoptimizeHTML.php(105): AO_Minify_HTML::minify()\n#7 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/autoptimizeMain.php(592): autoptimizeHTML->minify()\n#8 [internal function]: autoptimizeMain->end_buffering()\n#9 /home/otzerlin/public_html/wp-includes/functions.php(5464): ob_end_flush()\n#10 /home/otzerlin/public_html/wp-includes/class-wp-hook.php(324): wp_ob_end_flush_all()\n#11 /home/otzerlin/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()\n#12 /home/otzerlin/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()\n#13 /home/otzerlin/public_html/wp-includes/load.php(1279): do_action()\n#14 [internal function]: shutdown_action_hook()\n#15 {main}\n thrown in /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php on line 212\n
2025-03-08 18:40:48.426253 [NOTICE] [3454450] [T0] [127.0.0.1:49180#APVH_otzerling.com:443] [STDERR] PHP Fatal error: Uncaught JSMin_UnterminatedStringException: JSMin: Unterminated String at byte 187: "Hola a todos in /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php:212\nStack trace:\n#0 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(150): JSMin->action()\n#1 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(84): JSMin->min()\n#2 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(257): JSMin::minify()\n#3 [internal function]: AO_Minify_HTML->_removeScriptCB()\n#4 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(108): preg_replace_callback()\n#5 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(47): AO_Minify_HTML->process()\n#6 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/autoptimizeHTML.php(105): AO_Minify_HTML::minify()\n#7 /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/autoptimizeMain.php(592): autoptimizeHTML->minify()\n#8 [internal function]: autoptimizeMain->end_buffering()\n#9 /home/otzerlin/public_html/wp-includes/functions.php(5464): ob_end_flush()\n#10 /home/otzerlin/public_html/wp-includes/class-wp-hook.php(324): wp_ob_end_flush_all()\n#11 /home/otzerlin/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()\n#12 /home/otzerlin/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()\n#13 /home/otzerlin/public_html/wp-includes/load.php(1279): do_action()\n#14 [internal function]: shutdown_action_hook()\n#15 {main}\n thrown in /home/otzerlin/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php on line 212\n
2025-03-08 17:21:07.303341 [INFO] [3454451] [T0] [127.0.0.1:37656#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:20:58.899682 [INFO] [3454450] [T0] [127.0.0.1:40088#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:20:58.899662 [INFO] [3454450] [T0] [127.0.0.1:40088#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-includes/IXR/], access denied
2025-03-08 17:20:33.299505 [INFO] [3454451] [T0] [127.0.0.1:36504#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:20:33.299486 [INFO] [3454451] [T0] [127.0.0.1:36504#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-content/upgrade/], access denied
2025-03-08 17:20:08.958898 [INFO] [3454450] [T0] [127.0.0.1:57290#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:20:08.958878 [INFO] [3454450] [T0] [127.0.0.1:57290#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-admin/maint/], access denied
2025-03-08 17:19:58.787845 [INFO] [3454450] [T0] [127.0.0.1:32944#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:19:58.787807 [INFO] [3454450] [T0] [127.0.0.1:32944#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-admin/css/], access denied
2025-03-08 17:18:43.784816 [INFO] [3454450] [T0] [127.0.0.1:38902#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:18:43.784780 [INFO] [3454450] [T0] [127.0.0.1:38902#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-includes/], access denied
2025-03-08 17:17:47.456948 [INFO] [3454450] [T0] [127.0.0.1:33780#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:17:47.456905 [INFO] [3454450] [T0] [127.0.0.1:33780#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-content/uploads/2022/07/], access denied
2025-03-08 17:16:17.616514 [INFO] [3454451] [T0] [127.0.0.1:34486#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:16:17.616493 [INFO] [3454451] [T0] [127.0.0.1:34486#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-includes/Text/], access denied
2025-03-08 17:15:28.606968 [INFO] [3454449] [T0] [127.0.0.1:41428#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:15:28.606948 [INFO] [3454449] [T0] [127.0.0.1:41428#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-includes/css/dist/widgets/], access denied
2025-03-08 17:15:23.119860 [INFO] [3454450] [T0] [127.0.0.1:41372#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:15:22.090771 [INFO] [3454449] [T0] [127.0.0.1:58734#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:15:22.090739 [INFO] [3454449] [T0] [127.0.0.1:58734#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-admin/js/], access denied
2025-03-08 17:14:49.808834 [INFO] [3454450] [T0] [127.0.0.1:38684#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]
2025-03-08 17:14:49.808810 [INFO] [3454450] [T0] [127.0.0.1:38684#APVH_otzerling.com:443] Auto Index is disabled for [/home/otzerlin/public_html/wp-includes/js/tinymce/plugins/image/], access denied
2025-03-08 17:13:51.456836 [INFO] [3454449] [T0] [127.0.0.1:60136#APVH_otzerling.com:443] File not found [/home/otzerlin/public_html/403.shtml]OK, so the string “Hola te invitamos cordialmente a nuestras actividades de Agosto”, what page (URL) can I find that in?
-
This reply was modified 2 months ago by
- You must be logged in to reply to this topic.