johnnliu / UserCustomActionsConfigPage

The easiest way to add script to your SharePoint and SharePoint Online
33 stars 22 forks source link

Dependency loading issues #11

Closed devfacto-mandrada closed 7 years ago

devfacto-mandrada commented 7 years ago

I'm trying to figure out the best way to resolve this. I've got the following: [ScriptLink] Style Library/JavaScript/jquery-1.12.4.min.js ScriptSrc=null Sequence=1000 [ScriptLink] Style Library/JavaScript/bootstrap-3.3.7.min.js ScriptSrc=null Sequence=1001

As you can see, I have jQuery (1000) first, followed by Bootstrap (1001). When the site loads however, I get the following error:

Uncaught Error: Bootstrap's JavaScript requires jQuery

So it seems jQuery hasn't loaded completely yet before Bootstrap ran. Any ideas on how to resolve this?

sympmarc commented 7 years ago

Are you sure jQuery is actually loading? Check in the Developer Tools and make sure.

devfacto-mandrada commented 7 years ago

Yes, it is. In the right order too. And if I were to type in jQuery in the dev console, it doesn't show up as undefined.

Danny-Engelman commented 7 years ago

The Sequence only defines when a script starts loading, the scripts themselves are loaded async

Sorry for the tiny screenshot; I have 3 ScriptLinks they all start loading the moment they are called

We would be in alls sorts of performance and rendering problems if ScriptLinks were loaded in order

If you have dependencies you have to script them yourself

or bundle your scripts

http://sharepoint.stackexchange.com/questions/211805/custom-user-actions-js-injection-dependency

devfacto-mandrada commented 7 years ago

Thank you. That was my stackexchange question as well. For now, I'm loading bootstrap after jQuery, but will look into bundling if I run into loading more than those scripts.