fabiorino / crelly-slider

A free responsive slider for WordPress that supports layers. Add texts, images, videos and beautify them with transitions and animations.
MIT License
105 stars 36 forks source link

Inline javascript gives "JQuery not defined" when JQuery is loaded in footer #15

Open eduardoarandah opened 9 years ago

eduardoarandah commented 9 years ago

This causes problems when jQuery is loaded in footer.

How to reproduce

This plugin (from roots.io) loads Jquery from CDN and in footer: https://github.com/roots/soil

When installed, slider gives a "JQuery not defined"

Discussion

http://wordpress.stackexchange.com/questions/48530/how-do-i-make-script-load-after-jquery

Reference

https://codex.wordpress.org/Function_Reference/wp_enqueue_script

I don't know about best practices, know little about javascript. May be this could work:

eduardoarandah commented 9 years ago

I solved it!! (half the problem)

How:

  1. Parameters render as html attributes
  2. A JS function takes those parameters from inside the tag and executes crellySlider()

TODO

Sorry, I don't know much about javascript.

This is the file changed in a fork: https://github.com/eduardoarandah/crelly-slider/blob/master/wordpress/frontend.php

marcosignacio commented 5 years ago

You can modify frontend.php like this (lines 217+):

` // $output .= '' . "\n"; ?>

<?
    return $output;`
KuzMaxOriginal commented 4 years ago

I trust the best solution is to add an option in slider settings or shortcut arguments to load script after DOM is loaded:

document.addEventListener('DOMContentLoaded', () => {
  // here goes the code
});