• Resolved kodjoe

    (@agenceccmg)


    Hi I would like to load all smart-slider-3 plugin files after my theme files, so I decided to move them to footer, but how can I do that and which files from smart-slider-3 I need to specify ?

    At this time I have that:

    // Custom Scripting to Move JavaScript from the Head to the Footer
    function remove_head_scripts() {
    remove_action(‘wp_head’, ‘******’);
    remove_action(‘wp_head’, ‘******’, 9);
    remove_action(‘wp_head’, ‘******’, 1);

    add_action(‘wp_footer’, ‘******’, 5);
    add_action(‘wp_footer’, ‘******’, 5);
    add_action(‘wp_footer’, ‘******’, 5);
    }
    add_action( ‘wp_enqueue_scripts’, ‘remove_head_scripts’ );

    // END Custom Scripting to Move JavaScript

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Support Gabor

    (@nextendweb_gabor)

    Hi @agenceccmg!

    If you turn on JavaScript – Async:
    https://smartslider3.helpscoutdocs.com/article/457-global-settings-framework-settings
    then we will use JavaScript code to call in all our js files, which happens after the rest of the JavaScript files are called in by the website. So this way you wouldn’t have to move our files anywhere, they would load after your theme’s files.

    Thread Starter kodjoe

    (@agenceccmg)

    ahhhhhhh just perfect thanks a lot for this info !!! keep up the great work.

    Thread Starter kodjoe

    (@agenceccmg)

    Because I have this error but in a theme js file ? I can’t understand why I can’t swipe left and right in all my slider ?

    Uncaught TypeError: jQuery.easing[jQuery.easing.def] is not a function, here is my link: https://www.rental.booclin.ovh/la-villa-calado/

    Ramona

    (@nextend_ramona)

    Hi @agenceccmg

    Yes, that’s likely the cause. JavaScript errors stop every other JavaScript code on the page and prevent them from working, so they need to be solved.

    As I can see the error points to a theme related file, so I suggest reaching out to the theme developers and reporting them the problem. They should be able to provide the best solution.

    Thread Starter kodjoe

    (@agenceccmg)

    Ok but how can I put the script from your plugin in footer, because I’m sure my error is due to that jQuery is called before easing script it’s fully loaded.

    I need to not declare the script on the header and call it through jQuery’s .getScript() function when the document is fully loaded. Are you agree ?

    May be it happens because smart-slider requires wp_head and wp_footer in order to get to work properly with ajax calls. That means I’m probably calling header or footer twice.

    Ramona

    (@nextend_ramona)

    Hi @agenceccmg

    The JavaScript error you have isn’t coming from Smart Slider 3’s files, but form your theme’s: wp-content/themes/airtifact/js/main-build.js

    Moving our files won’t solve this error, because it’s not related to us.

    We don’t have option to put our codes to the footer, but optimization plugins (like Autoptimze) should be able to pick up the codes without problems and move them to the footer.

    Thread Starter kodjoe

    (@agenceccmg)

    let me see with them and this plugin in the same time ?? thanks a lot for your help

    Thread Starter kodjoe

    (@agenceccmg)

    Hi I have a question, i think jquery swing easing… is loaded twice, from your plugin and my theme, so how can I remove it from your plugin for example because I can’t remove it automatically from my theme ?

    Ramona

    (@nextend_ramona)

    Hi @agenceccmg

    Visit Global settings > Framework settings: https://smartslider3.helpscoutdocs.com/article/457-global-settings-framework-settings
    and turn off “Load jQuery on frontend”

    Thread Starter kodjoe

    (@agenceccmg)

    ah it’s already disable, I thought by turning on JavaScript – Async, I will have jQuery directly inside my script.

    Because today your plugin works fine with my theme only when I delete this part from my main-build.js, I’m sure the plugin already use this part of code and it does not work because it’s loaded twice , no ?

    // t: current time, b: begInnIng value, c: change In value, d: duration
    jQuery.easing[‘jswing’] = jQuery.easing[‘swing’];

    jQuery.extend( jQuery.easing,
    {
    def: ‘easeOutQuad’,
    swing: function (x, t, b, c, d) {
    //alert(jQuery.easing.default);
    return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
    return c*(t/=d)*t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
    return -c *(t/=d)*(t-2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
    if ((t/=d/2) < 1) return c/2*t*t + b;
    return -c/2 * ((–t)*(t-2) – 1) + b;
    },
    easeInCubic: function (x, t, b, c, d) {
    return c*(t/=d)*t*t + b;
    },
    easeOutCubic: function (x, t, b, c, d) {
    return c*((t=t/d-1)*t*t + 1) + b;
    },
    easeInOutCubic: function (x, t, b, c, d) {
    if ((t/=d/2) < 1) return c/2*t*t*t + b;
    return c/2*((t-=2)*t*t + 2) + b;
    },
    easeInQuart: function (x, t, b, c, d) {
    return c*(t/=d)*t*t*t + b;
    },
    easeOutQuart: function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t – 1) + b;
    },
    easeInOutQuart: function (x, t, b, c, d) {
    if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
    return -c/2 * ((t-=2)*t*t*t – 2) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
    return c*(t/=d)*t*t*t*t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
    return c*((t=t/d-1)*t*t*t*t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
    if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
    return c/2*((t-=2)*t*t*t*t + 2) + b;
    },
    easeInSine: function (x, t, b, c, d) {
    return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
    },
    easeOutSine: function (x, t, b, c, d) {
    return c * Math.sin(t/d * (Math.PI/2)) + b;
    },
    easeInOutSine: function (x, t, b, c, d) {
    return -c/2 * (Math.cos(Math.PI*t/d) – 1) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
    return (t==0) ? b : c * Math.pow(2, 10 * (t/d – 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
    return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
    if (t==0) return b;
    if (t==d) return b+c;
    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t – 1)) + b;
    return c/2 * (-Math.pow(2, -10 * –t) + 2) + b;
    },
    easeInCirc: function (x, t, b, c, d) {
    return -c * (Math.sqrt(1 – (t/=d)*t) – 1) + b;
    },
    easeOutCirc: function (x, t, b, c, d) {
    return c * Math.sqrt(1 – (t=t/d-1)*t) + b;
    },
    easeInOutCirc: function (x, t, b, c, d) {
    if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 – t*t) – 1) + b;
    return c/2 * (Math.sqrt(1 – (t-=2)*t) + 1) + b;
    },
    easeInElastic: function (x, t, b, c, d) {
    var s=1.70158;var p=0;var a=c;
    if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
    if (a < Math.abs(c)) { a=c; var s=p/4; }
    else var s = p/(2*Math.PI) * Math.asin (c/a);
    return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    },
    easeOutElastic: function (x, t, b, c, d) {
    var s=1.70158;var p=0;var a=c;
    if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
    if (a < Math.abs(c)) { a=c; var s=p/4; }
    else var s = p/(2*Math.PI) * Math.asin (c/a);
    return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
    },
    easeInOutElastic: function (x, t, b, c, d) {
    var s=1.70158;var p=0;var a=c;
    if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
    if (a < Math.abs(c)) { a=c; var s=p/4; }
    else var s = p/(2*Math.PI) * Math.asin (c/a);
    if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
    },
    easeInBack: function (x, t, b, c, d, s) {
    if (s == undefined) s = 1.70158;
    return c*(t/=d)*t*((s+1)*t – s) + b;
    },
    easeOutBack: function (x, t, b, c, d, s) {
    if (s == undefined) s = 1.70158;
    return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
    },
    easeInOutBack: function (x, t, b, c, d, s) {
    if (s == undefined) s = 1.70158;
    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t – s)) + b;
    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
    },
    easeInBounce: function (x, t, b, c, d) {
    return c – jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
    },
    easeOutBounce: function (x, t, b, c, d) {
    if ((t/=d) < (1/2.75)) {
    return c*(7.5625*t*t) + b;
    } else if (t < (2/2.75)) {
    return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
    } else if (t < (2.5/2.75)) {
    return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
    } else {
    return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
    }
    },
    easeInOutBounce: function (x, t, b, c, d) {
    if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
    return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
    }
    });

    Ramona

    (@nextend_ramona)

    Hi @agenceccmg

    If the “Load jQuery on frontend” is disabled, we don’t load jQuery to your site. These easing codes, however, are a different case, as that’s not loaded to most sites by default, and we need them for certain animations.

    I checked your site now and there’s a JavaScript error coming from the main.js file upon page load:
    Uncaught TypeError: $elm.airtifactFitVids is not a function
    which might be related to the issue.

    So first I suggest reaching out to the theme developers to get this error fixed, and maybe that solves the easing problem, too.

    Thread Starter kodjoe

    (@agenceccmg)

    oh I did not receive a notification for your answer.

    Thanks a lot for your answer, yes the error in my console from the main-build.js is the problem, if I resolve this error all works fine.

    But when I delete the js part that I sent you, it works fine even if the error is still visible in my console. that’s what I did not understand !!

    Ramona

    (@nextend_ramona)

    Hi @agenceccmg

    Do you mean that after the Uncaught TypeError: $elm.airtifactFitVids is not a function error is gone, you don’t need to remove the jQuery easing code to have everything working just fine?

    JavaScript errors prevent other JavaScript codes (that should run after them) from working properly, so if solving the $elm.airtifactFitVids error completely fixes the problem, then the solution is to leave this error fixed.
    In other words, the jQuery easing issue happened because of this error (not sure why, though), and the solution for this problem should remain.

    Thread Starter kodjoe

    (@agenceccmg)

    yep am agree but this error is a little hard for me to fix, I mean this error happened when this part of code with a script src is in my page:
    <script type=”text/javascript” src=”//static.lodgify.com/themes/shared/v3/assets/latest/embed-ldgfy-book.min.js” async=”async” style=”display:block!important” class=”embed-ldgfy-script-loader embed-ldgfy-book-script-loader” id=”lodgify-script-book-now-box” data-website-id=”272179″ data-website-slug=”antibesrental” data-domain=”lodgify.com” data-protocol=”https” data-property-id=”272026″ data-culture=”en” data-culture-iso=”en-US” data-currency=”EUR” data-token=”oHwmNCP072p3mNcyqkRacpa1rLCK7R2T+l2xFAYo8rfc+2vs3iDUxGI7oTEbRo5s”></script>

    this script break my theme and this error happened:
    Uncaught TypeError: $elm.airtifactFitVids is not a function

    the sliders does not working fine after that, but if I delete the jQuery easing part of my main-build.js even if the $elm.airtifactFitVids error is not solved, it works fine for me.

    That’s what I don’t really understand, and I don’t really know how to solve the error from my main-build.js, here is a my question but no one found the solution:
    https://stackoverflow.com/questions/59375089/how-to-embed-external-script-to-my-page-without-breaking-other-script/59376740#59376740

    Ramona

    (@nextend_ramona)

    Hi @agenceccmg

    If solving the Uncaught TypeError: $elm.airtifactFitVids is not a function fixed the problem, then the real solution for your case seems to be to get this error permanently fixed.

    As it’s coming from your theme, I’d suggest reaching out to the theme developers for the best solution.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘How to move smart-slider-3 js files to footer’ is closed to new replies.