This happens because your add-on js library isn't using amd properly but it trying to support it.
You can reset the require js definitions so the addon js library will work like this(this implementation assumes you DO NOT use AMD inside your custom script):
<metal:javascript fill-slot="javascript_head_slot">
<script>
require = undefined;
define = undefined;
</script>
<script src="++theme++osa/magnific-popup.js"></script>
<script src="++theme++osa/image-gallery-popup.js"></script>
</metal:javascript>
Or, you can simply use AMD ONLY and not use amd along with manually loading the js file:
include:
<metal:javascript fill-slot="javascript_head_slot">
<script src="++theme++osa/image-gallery-popup.js"></script>
</metal:javascript>
JS file:
require([
'jquery',
'++theme++osa/magnific-popup' // Note: no `.js`
], function($) {
$('.popup-gallery').magnificPopup();
});
Also, you can simply add the JS files at the bottom of the file and do not use to use the slots.