Foliovision › Forums › FV Player › Troubleshooting › SiteGround Optimizer issues
-
I am having an issue with a Javascript error when I am not logged as the WP Admin. It works fine when logged in. I was doing a demo to someone and that is how I found out… (embarrassing) The page I have tested on it https://IWant2BeFree.com/plan-b as well as https://IWant2BeFree.com/home-video.
After researching and finding no errors in the server error logs I am requesting some suggestions! ;) (a few days of searching and changing of settings… nothing made a difference). This is a newer install so this is the only version of FV Player I have installed. The website is a fairly new build as well. So all of the latest version are installed.The standard home page was hand coded and the FV Player offers a cleaner installation.Sincerely,
Paul
-
-
Hello Paulc,
it seems you are using
defer
for all JavaScript on your page except forplugins/fv-wordpress-flowplayer/flowplayer/modules/flowplayer.min.js
. Please apply the samedefer
on it and it will load properly.Your video won’t play though as you use page cache (there is a
x-proxy-cache
header). The Amazon S3 signed URLs are time-sensitive, please checks the instructions for cache plugins here: https://foliovision.com/player/video-hosting/amazon-s3-guide#bucket-protection-in-fvplayer-settingsThanks,
MartinHello Paulc,
what plugin do you use to defer the JavaScript? It seems to be SiteGround Optimizer.
I had a look and they start the deferring optimization on the wp_print_scripts action with SiteGround_Optimizer\Front_End_Optimization::prepare_scripts_for_async_load() which occurs in the page
<head>
section:add_action( 'wp_print_scripts', array( $this->front_end_optimization, 'prepare_scripts_for_async_load' ), PHP_INT_MAX );
With FV Player we only load the scripts if they were used on the page. We can only do that in the website footer so we use
wp_footer
action. It seems SiteGround Optimizer should utilize wp_print_footer_scripts action to cover these footer scripts too.Please ask them to incorporate this line of code right below where they normally hook in
prepare_scripts_for_async_load
and it should work:add_action( 'wp_print_footer_scripts', array( $this->front_end_optimization, 'prepare_scripts_for_async_load' ), PHP_INT_MIN );
That way SiteGround Optimizer will optimize also the scripts which load in footer.
Thanks,
MartinI did receive a response from SG Support… this was what they stated:
Hello Paul,
I have reviewed the reported case and the actual error that the FV Player was generating due to the “Defer Render-blocking JavaScript” function is the one below.
It appears there are no jQuery library on your site, your videos might not be playing, please check.
In order to resolve this, I have used the “Exclude from Deferral of Render-blocking JS” function of our Optimizer plugin to exclude the .js which is responsible for the jQuery library and is used by FV Player, and the error is no longer present.
However, the other error below that this plugin is generating does not appear to be related to our function
It appears there are no Flowplayer scripts on your site, your videos might not be playing, please check. Check your template’s header.php file if it contains wp_head() function call and footer.php should contain wp_footer()!
This error is caused by the “Combine JavaScript Files” function, I have attempted to exclude the FV Player scripts from it, however, they appear to be loaded inline, due to which this needs to be done with the filter below by adding it to the functions.php file of your website.
add_filter( 'sgo_javascript_combine_excluded_inline_content', 'js_combine_exclude_inline_script' ); function js_combine_exclude_inline_script( $exclude_list ) { $exclude_list[] = 'first few symbols of inline content script'; return $exclude_list; }
I was not able to find the exact handle that the scripts use, due to which my attempts for this were unsuccessful, hence it would be best for you to reach out to FV Player’s support and ask them for the exact script handles they are using, after which they can be excluded with the filter above.
However, if the scripts are queued normally, then the filter that needs to be used is:
add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' ); function js_combine_exclude( $exclude_list ) { $exclude_list[] = 'script-handle'; $exclude_list[] = 'script-handle-2'; return $exclude_list; }
For the time being, I have disabled the “Combine JavaScript Files” function and this error is no longer present as well:
In regards to the notice that you have received, this was due to my attempts to exclude the scripts in question via the above-provided filters.
Should you require any further assistance from our end, please let us know.
Best regards,
Technical Support TeamThey did put the changes back… I received a message about the website stability… but, then I discovered they were doing diagnostics. That response is above!
Sincerely,
PaulHello Paulc,
it’s good to see SiteGround has working support. However they only get rid of the optimizations.
The code changes which I proposed would fix their optimizations to work with FV Player – and any other plugin that loads scripts in footer. Please ask them to have a look at that too.
Thanks,
MartinSo I heard back once again from Technical Support:
Hello Paul,
As my colleagues previously suggested, the error on the web page is related to the “Combine JavaScript Files” feature of SiteGround Optimizer, and the suggested fix from the third-party plugin is related to the “Defer Render-blocking JavaScript” functionality.
In any case, our plugin offers the option to exclude certain scripts or files from the Frontend optimization features. You can find more information about these options in our plugin documentation here:
https://wordpress.org/plugins/sg-cachepress/
Upon reviewing the case, I was able to resolve the issue by excluding one of the scripts on the site from the “Combine JavaScript Files” feature of our plugin. I added the following to the functions.php file of the WordPress theme:
add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' ); function js_combine_exclude( $exclude_list ) { $exclude_list[] = 'flowplayer'; return $exclude_list; }
This way the “Check template” checker no longer generates errors with “Combine JavaScript Files” enabled:
This way the site is using both “Combine JavaScript Files” and “Defer Render-blocking JavaScript” and there are no errors that are generated. Please review your website in order to make sure that it is working as expected.
Should you need further assistance you can reach us back anytime!
Best Regards,
Technical Support TeamEverything appears to be working and no errors are occurring. ;)
Sincerely,
PaulHello Paulc,
it’s too bad they did not consider the improvements to their website optimization plugin.
I found that if I simply enable both “Combine JavaScript Files” and “Defer Render-blocking JavaScript” in SiteGround Optimizer then FV Player just works.
I summed up my findings in our Minify plugins guide: https://foliovision.com/player/developers/player-minify-plugins#siteground-optimizer
I also see that our Check Template function does not work if the script files are combined into one. I added a check for that.
If you have some time it would be great if you could reinstall FV Player from this link: http://foliovision.com/downloads/fv-wordpress-flowplayer.zip To do that you will have to first deactivate and delete the current FV Player plugin you are using. WordPress will warn you that you might loose settings and data, but it’s not the case with our plugin, no settings now videos will be lost. Or you can just replace the plugin files via FTP.
Then you can just remove any of the code additions done by SiteGround support and your videos will continue playing.
Thanks,
Martin