-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDN with local fallback #146
Comments
Hacky solution / workaround: if (typeof SubscribeButton == 'undefined') {
document.write(unescape("%3Cscript class=\"podlove-subscribe-button\" src=\"https://publisher.dev/wp-content/plugins/podlove-publisher/lib/modules/subscribe_button/dist/javascripts/app.js\" data-json-data=\"podcastDataa209f41320cdd9\" data-language=\"de\" data-size=\"big auto\" data-format=\"cover\" data-style=\"filled\" data-color=\"#75ad91\"> %3E%3C/script%3E"));
window.setTimeout(function() {
iframes = document.querySelectorAll('.podlove-subscribe-button-iframe')
for (i = 0; i < iframes.length; ++i) {
if (!iframes[i].style.width && !iframes[i].style.height) {
iframes[i].style.display = 'none';
}
}
}, 5000);
} Explanation: 5 seconds after loading the fallback, I check all button iframes if they have a width and style css set. If not, that means they were not initialized and I can hide them. It's not a great solution but better than showing no button at all when the CDN is not available. Curious if you have ideas to improve on this. |
This would be a great improvement. |
This approach is already used with success in the Publisher https://github.com/podlove/podlove-publisher/blob/master/lib/modules/subscribe_button/button.php#L111 |
perfect! I will add this to the next version of the standalone plugin. |
Great :) Close when it's committed. |
Would it be possible to give us a complete option to run the app locally? Right now, using the plugin always uses the CDN and this apparently can't be disabled. It would be great for those of us who don't want to run any external code on our site. |
I want to use the CDN but fall back to a local button if the CDN is not reachable. This is what I came up with:
It kind of works. This is the result:
The fallback button is rendered correctly but the failed CDN script still creates the iframe and style nodes which take up vertical space. Ideas how I can make this work?
The text was updated successfully, but these errors were encountered: