Opera mini resuming paused js

168 Views Asked by At

Ive been reading up on opera mini and running javascript on it. https://dev.opera.com/articles/opera-mini-and-javascript/

The opera website says you can add an event listener to your scripts and have them resume on a user initiated action.

What actions would be supported by opera mini that i can use to resume a script and how do i integrate the event listener into my current js?

For example i have this image carousel which had this script on my page:

<script type="text/javascript">
$(document).ready(function(){
 $('.responsive-mq').slick({

        dots: true,
        infinite: true,
        speed: 300,
        slidesToShow: 4,
        slidesToScroll: 4,
        lazyLoad: 'ondemand',
        autoplay: true,
        autoplaySpeed: 2000,

        mobileFirst: true,

        responsive: [
            {
                breakpoint: 1024,
                settings: {
                    speed: 300,
                    slidesToShow: 5,
                    slidesToScroll: 5,
                    infinite: true,
                    dots: true,
                    autoplay: true,
                    autoplaySpeed: 2000
                }
            },
            {
                breakpoint: 600,
                settings: {
                    slidesToShow: 3,
                    slidesToScroll: 2
                }
            },
            {


                breakpoint: 500,
                settings: {
                    dots: true,
                    infinite: true,
                    speed: 300,
                    slidesToShow: 2,
                    slidesToScroll: 1,
                    autoplay: true,
                    autoplaySpeed: 2000

                }
            },
            {

                breakpoint: 480,
                settings: {
                    slidesToShow: 3,
                    slidesToScroll: 3

                                    }
            },
            {


                breakpoint: 199,
                settings: {
                    dots: true,
                    infinite: true,
                    speed: 300,
                    slidesToShow: 2,
                    slidesToScroll: 2,
                    autoplay: true,
                    autoplaySpeed: 2000

                }
            }
        ]



    });


});

But then has its own js file with heaps of scripting in it. Would i only have to use the listener on the on page script?

I'm only a beginner with js so please keep that in mind.

1

There are 1 best solutions below

1
On

Basically when you load a webpage in Opera Mini, then you get something like a screenshot of it. This screenshot may be reloaded on user action (like click or form submit), but will not reload automatically, so it would be best if you disabled carousel for Opera Mini users. You can just stack slides one under each other. This way users don't have to reload the page to see the content.

You could probably modify your code like so:

var isOperaMini = Object.prototype.toString.call(window.operamini) === "[object OperaMini]";
if (!isOperaMini) {
   $('.responsive-mq').slick(...);
}

But remember to check this in Opera Mini as I'm not entirely sure it will work with your site and this Slick plugin.