[Resolved] Js Defer problem

Status
Not open for further replies.
#1
Good morning and compliments for the work you do. However, the js option defer me to problems, when the active button looks and the menu on mobile does not work. How can I fix it? thank you
 

Jon K

Administrator
Staff member
#2
We are aware of this compatibility issue, it caused by the inline script which directly used jquqery without waiting for document ready (not fully loaded page). We are working on a fix.
 
#3
Looking forward to se a fix for this problem. For me js defer also create a problem with the page title bar. Keep on the good work.
 
#5
Hi @Unique_Eric I am using version 1.7 and still running into this issue and I can see that Litespeed cache has moved the query file to the far bottom of the page which means that inline scrips that are relying on Jquery are triggering errors messages. To be exact the error message says: Uncaught ReferenceError: jQuery is not defined at (index):106

I have tried Exclude Jquery (both on an off - currently on), Exclude URI etc with no success. Maybe it is is broken a gain?

I would really appreciate your help

Cheers,

Zan
 
Last edited by a moderator:

hai

Well-Known Member
#6
When you enable Exclude JQuery, the jquery should be in the top of the page. Can you give a page or a report number so we can check?
 
#7
When you enable Exclude JQuery, the jquery should be in the top of the page. Can you give a page or a report number so we can check?
Thanks Hai,
I ideally wouldn't want it at the top of the page either. I have moved it to the bottom of the page but put other scripts that rely on it beneath it. I ideally would want Litespeed cache to just leave it alone exactly where it was at the bottom but the last item. Putting it at the top would slow down the rendering of the page.

I am having problems posting a link on here
 
#8
Thanks Hai,
I ideally wouldn't want it at the top of the page either. I have moved it to the bottom of the page but put other scripts that rely on it beneath it. I ideally would want Litespeed cache to just leave it alone exactly where it was at the bottom but the last item. Putting it at the top would slow down the rendering of the page.

I am having problems posting a link on here
Add the following up to get the url please: home loans compare. co. nz /balance-transfer-credit-cards/
 
Last edited by a moderator:

hai

Well-Known Member
#9
As long as you turn on JS defer, it won't slow down your page loading. Also if you have HTTP/2 push on, it will be faster.

WP puts JQ before <body> tag, if you move it to bottom, you added a new one manually? In this case, you can disable LSCWP's optimizer to move it by adding attribute data-no-optimize='1' to your jq.
 
Last edited by a moderator:
#10
Thanks Hai. What do you mean by adding attribute data-no-optimize='1' to your jq. You mean open up javascript and add this to the code?
 
Last edited by a moderator:

Tishu

Well-Known Member
#11
Hello,
You need to add that data-no-optimize='1' when you are loading the JQ ( in <script src=.... ).
 
Last edited by a moderator:
#12
Thank you so much for your help guys adding that to the jQuery script fixed the problem. I love LiteSpeed Cache btw.
For benefits of others, just to be clear, you can add data-no-optimize='1' to your script tag as shown below to stop LiteSpeed Cache from optimising it and so it won't be moved around. It basically tells LiteSpeed cache that the script has already been optimised and should be left alone is what I gather.
<script type='text/javascript' data-optimized='1' src='https://www.creditcardscompare.co.nz/wp-includes/js/jquery/jquery.js'>
 
Last edited by a moderator:
Status
Not open for further replies.
Top