Skip to content

bundle-common.js and page specific bundle-*.js is loaded 2 times on the page load #177

@salmanazeez786

Description

@salmanazeez786

I see that the bundle-* files are loading twice on the Homepage, PLP and PDP pages for which I have created the magepack bundles
image

Further looking in the code , I see the layout xmls are adding the bundle-common.js & page specfic bundle-*.js in the head section,

cms_page_view.xml
<body>
        <referenceBlock name="magepack.bundles">
            <arguments>
                <argument name="page_bundles" xsi:type="array">
                    <item name="cms" xsi:type="array">
                        <item name="config_path" xsi:type="string">magepack/requirejs-config-cms.js</item>
                        <item name="bundle_path" xsi:type="string">magepack/bundle-cms.js</item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>

But the same bundle-common.js and page specfic bundle-*.js is also added as a prefetch link in phtml templated which loads in all pages

MageSuite_Magepack::bundles-loader.phtml

<?php if ($commonBundleUrl): ?>
<link rel="prefetch" as="script" href="<?= $commonBundleUrl; ?>"/>
<?php endif; ?>

<?php foreach($pageBundlesUrls as $pageBundleUrl): ?>
<link rel="prefetch" as="script" href="<?= $pageBundleUrl; ?>"/>
<?php endforeach; ?>

Is this expected ? or can we remove the prefetched ones ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions