• Resolved fidoboy

    (@fidoboy)


    I’m not sure why but the button is not being displayed on mobile devices, but it works fine on desktop. I’m using Newspaper theme. There is no Javascript errors when looking at the console, but the HTML structure is not being created into the wrapper.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Contributor Atlas AiDev

    (@atlasaidev)

    Please add the page where you’re facing this issue.

    We’ve tested on our end it’s working fine.

    Thread Starter fidoboy

    (@fidoboy)

    I can’t publish the page but there is nothing to see, the button is just not being displayed and the HTML structure keeps as it is:

    <tts-play-button data-id="1" class="tts_play_button wp-dark-mode-ignore"></tts-play-button>

    There is no Javascript errors thrown or PHP errors or warnings into the log.

    Plugin Author Azizul Hasan

    (@hasanazizul)

    Thread Starter fidoboy

    (@fidoboy)

    thanks. I’ve readed it and it’s OK. I can see the button working here: https://atlasaidev.com/text-to-speech/ with the same browser/device. So it’s not a matter of lack of support for a particular device. It seems to be some kind of plugin code issue causing incompatibilities with other plugins in WordPress.

    The rendering method being used is Javascript so I wonder if it’s not possible to generate all the HTML structure using PHP instead.

    Thread Starter fidoboy

    (@fidoboy)

    I’ve discovered that the problem comes only if I enable WP Rocket cache plugin. So may be there is an issue with deferred or delayed javascripts.

    Thread Starter fidoboy

    (@fidoboy)

    It’s very weird because I’m trying to debug it to look for the cause and can’t see the point. I’m using a desktop Chrome browser right now. If I load any post the button is being displayed without any problem BUT if I select the mobile viewer into browser DevTools and I reload the same page, then the button is NOT displayed without having any error. The page source code is the same, I’ve checked it.

    Thread Starter fidoboy

    (@fidoboy)

    @hasanazizul it seems a matter of timings, cause reloading the page and forcing to bypass the browser cache sometimes the button is being displayed but it doesn’t work others. So there is some kind of issue in your Javascript.

    Thread Starter fidoboy

    (@fidoboy)

    Hi again @hasanazizul

    Problem is with text-to-audio-button.min.js that uses a very weak way to create the HTML structure. There is a setTimeout function that it’s a NOT recommended way to interact with document DOM structure. This setTimeout is where it checks the existence of a window property and then it creates the HTML elements. But this fails for many reasons, so it’s not the best way to do it. You should use window events like document ready or other methods to know when the script should fire to create the button.

    In my particular case it works almost all the time on desktop and also sometimes on mobile devices when I bypass the WordPress cache and also the browser cache, but it fails many times. So it’s not very stable or rock solid procedure your current method. As I’ve said, it’s not a nice practice to use timeouts to accomplish task like this one.

    May be you can consider using jQuery (already included with WordPress) to fire your procedure when the document is ready.

    • This reply was modified 1 year, 1 month ago by fidoboy.
    Plugin Contributor Atlas AiDev

    (@atlasaidev)

    Hi @fidoboy ,

    Thank you so much for your findings. We appreciate it. Can you please mention the plugins name that prevents the button issue.

    Thread Starter fidoboy

    (@fidoboy)

    At the very first moment I thought that was caused by the cache (Docket cache plugin in my particular case) but I finally discovered that it’s not the issue. It has to be with the server response and page rendering times. Even when I did my tests using the desktop browser and using the DevTools simulating a mobile device view, it failed many times. And it was solved by simply reloading a few times the page or activating the checkbox to avoid the browser cache.

    So as I said in my previous comment the problem is being caused by the Text to speech TTS plugin Javascript used in front-end. Your script is using a setTimeout function to create the HTML button structure and it fails. So it could be way much better to use the document ready event to fire up your routine. It shouldn’t be very difficult to do the necessary changes for the next version that you release.

    Just tell me if you need more info.

    • This reply was modified 1 year, 1 month ago by fidoboy. Reason: Mistake
    Thread Starter fidoboy

    (@fidoboy)

    You can see the info here:

    https://learn.jquery.com/using-jquery-core/document-ready/

    Or here if you do not want to use jQuery:

    https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event

    You need to remove your setTimeout function and replace it with one of the methods that fires when the document is fully loaded.

    • This reply was modified 1 year, 1 month ago by fidoboy. Reason: Add better explanation
    Thread Starter fidoboy

    (@fidoboy)

    @atlasaidev Any news on this issue? Latests releases doesn’t change anything. Also it could be nice if you incude a “part” attribute into the shadow tree to allow CSS customizing.

    Plugin Contributor Atlas AiDev

    (@atlasaidev)

    Hi,
    The way you’re suggesting this is not possible.
    If want to know why then you can contact with us.

    To add custom CSS class in the shadow tree you can do this by adding a “class” attribute in the shorcode like this

    [tta_listen_btn class="custom_class"]

    But you can’t access it from outside. You can only access it from the customization menu of Text To Speech plugin.

    Thread Starter fidoboy

    (@fidoboy)

    I disagree. It’s possible because I’ve tested it and it works. Can’t understand why you are using that unstable method as setTimeout without checking for page load.

    And about the other issue, the matter is that I need to access from outside because I’m using a dark mode plugin that switches the page colors. So it’s not possible to do from the plugin css customization.

    Plugin Contributor Atlas AiDev

    (@atlasaidev)

    And about the other issue, the matter is that I need to access from outside because I’m using a dark mode plugin that switches the page colors. So it’s not possible to do from the plugin css customization.

    This is possible in the pro version.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Button not being rendered on mobile devices’ is closed to new replies.