0

I am doing a js injection using custom action.

I am loading jquery first and then my custom js. I have applied sequence in custom action 0 for jquery and 100 fro my custom javascript.

My problem is some time jquery not load before my custom javascript so i got error $ is not defined.

I am using jquery CDN.

0

In your custom js file you can check whether jQuery has loaded or not. If not loaded then you can manually load it and then continue with your script.

if (typeof jQuery != 'undefined') {
    alert("jQuery library is loaded!");
    SP.SOD.executeFunc("jQuery.js, null, CustomScriptInit);
}

function CustomScriptInit() {
    //Custom script starts here
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.