If it is suitable to your context (worked for me), the basic way to prevent MapkitJS to block JS execution is to include the script with the "defer" keyword and adapt your JS code calling Mapkit to be executed only after Mapkit is loaded:
in header:
<script defer src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>
in your page:
<script type="text/javascript">
// ready function taken from http://youmightnotneedjquery.com/#ready
function ready(fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
// mapkit init only after mapkit is loaded, here is my init code as a sample
ready(function() {
mapkit.init({
authorizationCallback: function(done) {
done('[mapkitToken]');
}
});
var mapregion = new mapkit.CoordinateRegion(
new mapkit.Coordinate([latitude], [longitude]),
new mapkit.CoordinateSpan(0.15, 0.15)
);
var map = new mapkit.Map("map-container");
map.isRotationEnabled = false;
map.showsScale = mapkit.FeatureVisibility.Visible;
map.region = mapregion;
});
</script>