Site logo

Archived topic

How to exclude a script

3 replies · Started by Samuel on October 29, 2022

Viewing posts 1–4 of 4

Hi,

I'm using a script to open a specific part of my sub-menu to the left.
I'm using Litespeed cache to delay JS
And so the script is not working.

So I need to exclude the script from being delayed.

But I can't find which attribute I need to set to exclude it. As Litespeed is authorizing all king of exclusion, including simple keyword that is part of the JS I've tried to exclude part of the code, like (jQuery('ul', this) or main-navigation but it's not working.

Here is the script :

<script>
	jQuery(function () {
    jQuery(".main-navigation ul ul li").on('mouseenter mouseleave', function (e) {
        if (jQuery('ul', this).length) {
            var elm = jQuery('ul', this);
            var off = elm.offset();
            var l = off.left;
            var w = elm.width();
            var docH = jQuery("body").height();
            var docW = jQuery("body").width();

            var isEntirelyVisible = (l + w <= docW);

            if (!isEntirelyVisible) {
                jQuery(this).addClass('edge');
                console.log('out of bounds');
            } else {
                jQuery(this).removeClass('edge');
            }
        }
    });
});</script>

Maybe there would be a way to "name" this script in order to exclude it calling by its name ?

Thanks for your help

Hi there,

you may want to check with Litespeed support.
Before that, try a longer pattern to check eg.

jQuery(".main-navigation ul ul li").on('mouseenter mouseleave', function (e) {

Thanks David,
This is not working,
I'll see with Litespeed support, or I'll change my menu to not be so deep and to not need this feature.

I hope they can help :)

This archived topic is closed to new replies.