0

I've been struggling to get jquery and our master scripts file to defer and execute one after another (thanks, Google's Pagespeed)

I've used various methods, including require, LAB and the classic document.createElement method.

However - the JS files are being loaded async - and I believe that while JQuery is being downloaded, our master file is being downloaded - which throws errors in the console because JQuery hasn't completed yet.

Refresh the page and it's occasionally working - so I believe this is the problem.

Does anyone have any advice on deferring scripts, but loading and executing them not in parallel?

2
  • requirejs.org Commented Jun 30, 2017 at 10:58
  • take a look at the loading system octobercms uses. It uses a "render" jquery event to indicate something refreshed, and the scripts listen to that specific event to start execution, look for elements to bind to, etc... Commented Jun 30, 2017 at 12:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.