Title: Javascript errors on two themes
Last modified: August 21, 2016

---

# Javascript errors on two themes

 *  Resolved [mlargue](https://wordpress.org/support/users/mlargue/)
 * (@mlargue)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/)
 * Firstly, I love your plugin. It makes an incredible difference to my site load
   speeds. I hope you can help me with a couple of problems that I am encountering,
   that I have definitely isolated to your plugin.
 * The two themes that are affected, are the ThemeForest Avada and Enfold themes.
   Both themes use a sticky menu and a modal search pop-up (this appears to be a
   consistent factor). Both of these pieces of functionality break when WP Defer
   Loading is activated, and the following errors are displayed through Chrome:
 * Avada: Uncaught SyntaxError: Unexpected token .
 * Enfold: Uncaught SyntaxError: Unexpected token ILLEGAL
 * It goes without saying that this functionality works with no error when WP Defer
   Loading is deactivated.
 * [https://wordpress.org/plugins/wp-defer-loading/](https://wordpress.org/plugins/wp-defer-loading/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [bassjobsen](https://wordpress.org/support/users/bassjobsen/)
 * (@bassjobsen)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057301)
 * Hi [@mlargue](https://wordpress.org/support/users/mlargue/),
 * Thanks for posting your issue. Are you enabled to show me an url with the errors.
   I can’t don’t download the themes you mentioned, cause there is no free version.
   
   Most issues are caused by script not enqueued well, as i also describe on my 
   blog: [http://bassjobsen.weblogs.fm/wordpress-development-properly-load-javascript-set-dependency/](http://bassjobsen.weblogs.fm/wordpress-development-properly-load-javascript-set-dependency/)
 * On theme-fusion.com/avada/ i found some javascript which requires jquery which
   not has been enqueued. I also found an other demo at [http://www.kriesi.at/themes/enfold/](http://www.kriesi.at/themes/enfold/).
   On the first sight in did not found any javascript written directly to the page
   source. But both demos also use other plugin to merge javascripts.
 *  Thread Starter [mlargue](https://wordpress.org/support/users/mlargue/)
 * (@mlargue)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057302)
 * Hi Bass
 * Thanks for the prompt response. The two sites are:
 * easteam.co and quixpix.com.
 * I will activate your plugin so that you can see the problems Bear in mind that
   the sticky menu and navbar search modals should normally work. I am in the process
   of baselining speed, so there is nothing other than the standard install of the
   theme.
 * Regards
    Michael
 *  Thread Starter [mlargue](https://wordpress.org/support/users/mlargue/)
 * (@mlargue)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057307)
 * Hi Bass
 * Don’t worry about quixpix.com, I think I may have a solution. I am still interested
   in your feedback on easteam.co though.
 * Regards
    Michael
 *  Thread Starter [mlargue](https://wordpress.org/support/users/mlargue/)
 * (@mlargue)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057322)
 * Hi Bass
 * Don’t worry about quixpix.com either. Thanks for the help.
 * Regards
    Michael
 *  Plugin Author [bassjobsen](https://wordpress.org/support/users/bassjobsen/)
 * (@bassjobsen)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057324)
 * Hi Michael,
 * Thank for sharing your sites.
    I found the problem related to carriage returns
   inside the theme javascript settings (which are enqueued well).
 * Are you able to test the latest version from github? [https://github.com/bassjobsen/wp-defer-loading/archive/master.zip](https://github.com/bassjobsen/wp-defer-loading/archive/master.zip)
 * Thanks!
 *  Thread Starter [mlargue](https://wordpress.org/support/users/mlargue/)
 * (@mlargue)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057339)
 * Hi Bass
 * I still receive the same error messages. This optimisation process can be rather
   complex – no silver bullet : )
 * I am now looking at using an alternative theme. I will keep you posted.
 * Regards
    Michael
 *  Plugin Author [bassjobsen](https://wordpress.org/support/users/bassjobsen/)
 * (@bassjobsen)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057352)
 * Hi Michael,
 * I installed the avada theme (i found a had a license for that theme already) 
   to investigate the problem. Unfortunately i found many issues related to this
   theme.
 * Your original “Avada: Uncaught SyntaxError: Unexpected token.” error was initiated
   by a bug in my plugin. I have fixed this bug already (download the latest version
   from github).
 * Theme issues found:
    1. The Avada does not set dependency of jquery for most of their scripts. In the
       code you will find for instance:
    2.     ```
           wp_deregister_script( 'jquery.flexslider' );
           	    wp_register_script( 'jquery.flexslider', $template_directory . '/js/jquery.flexslider-min.js', array(), null, true);
           		wp_enqueue_script( 'jquery.flexslider' );
           ```
       
    3. The empty `array` in the `wp_register_script` call should contain jquery, cause
       jquery.flexslider depends on jquery
    4.  The theme also includes a main.js file by `wp_register_script( 'avada', $template_directory.'/
       js/main.js',array(), null, true);`
        This script contain among others a copy 
       of Bootstrap’s scrollspy plugin. When defer loading main.js (which also depends
       on jquery in the first place) the scrollspy has been called before initiated(
       i think main.js should set depended of scrollspy which should be loaded in an
       separated file). Also notice that Bootstrap’s plugins can not defer load (or
       after the document.load event in this case), see also: [https://github.com/twbs/bootstrap/issues/14023](https://github.com/twbs/bootstrap/issues/14023)
       There seems to be a similar issues with the `.placeholder call`
    5.  The theme requires other plugins such as revslider which also don’t have set
       the jquery dependency (probably also relate to [http://wordpress.org/support/topic/rev_slider-not-loading](http://wordpress.org/support/topic/rev_slider-not-loading))
 * I will write a note to the developers of Avada later on. I don’t know if they
   are willing to fix some of the problems mentioned above. Currently the plugin
   don’t support the Avada theme. I’m sorry for that.
 *  Thread Starter [mlargue](https://wordpress.org/support/users/mlargue/)
 * (@mlargue)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057354)
 * Hi Bass
 * Thank you very much. Definitely above and beyond what I expected : ) I think 
   I will definitely be moving on from this theme, at least until they remedy the
   many problems. I know they are looking at a version 4.
 * Many thanks
    Michael

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Javascript errors on two themes’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-defer-loading.svg)
 * [WP Defer Loading](https://wordpress.org/plugins/wp-defer-loading/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-defer-loading/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-defer-loading/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-defer-loading/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-defer-loading/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [mlargue](https://wordpress.org/support/users/mlargue/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/javascript-errors-on-two-themes/#post-5057354)
 * Status: resolved