@alirz23 I already did it and actually it coused, that my script goes aftes yii.js in source of the page, but that didn’ solve the problem. My script is small and I think that it is executec before yii.js managed to initialise it’s root js module. As bad workaround it is anough to wait 10ms in my script or put CSRF into AJAX manually. I’m not satisfied with them.
adding dependencies to asset caused that /js/scripts.js went after yii.js, but it is not enough.
To debug i placed alert() in:
at the beginning of yii.js
at the beginning of scripts.js
in initCsrfHandler() in yii.js
in jQuery(window).on(‘load’, function () in my script scripts.js
On Chrome I got the following order: 1,2,3,4 and everythin is fine. CSRF handler is initialised before window load.
On Edge, IE, Samsung Galaxy S9 the order is 1,2,4,3 !.
So CSRF handler is not initialised before my first ajax call in on load.