diff --git a/vendor/magento/module-require-js/Block/Html/Head/Config.php b/vendor/magento/module-require-js/Block/Html/Head/Config.php
index 9e89a18a03c9..8a02adde8b59 100644
--- a/vendor/magento/module-require-js/Block/Html/Head/Config.php
+++ b/vendor/magento/module-require-js/Block/Html/Head/Config.php
@@ -75,7 +75,7 @@ public function __construct(
      */
     protected function _prepareLayout()
     {
-        $after = RequireJsConfig::REQUIRE_JS_FILE_NAME;
+        $after = $this->getInsertAfter() ?: RequireJsConfig::REQUIRE_JS_FILE_NAME;
         $assetCollection = $this->pageConfig->getAssetCollection();
         if ($this->minification->isEnabled('js')) {
             $minResolver = $this->fileManager->createMinResolverAsset();
