0

We are building Lightning Web Components for a Community and we're leveraging a 3rd party library to help with some charts/widgets. Each chart is it's own component and uses the platformResourceLoader to load the required resources (as below)

        Promise.all([
        loadStyle(this, communityDashboards + '/css/main.css'),
        loadStyle(this, devExtreme + '/dx.common.css'),
        loadStyle(this, devExtreme + '/dx.greenmist.css'),
        loadScript(this, jquery341 + '/jquery-3.4.1.min.js'),
        loadScript(this, devExtreme + '/dx.all.js')
    ])
        .then(() => {
            console.log('Successfully loaded Static Resources');
            this.renderPie();
        })
        .catch(error => {
            console.log('Error loading Static Resources');
            console.log(JSON.stringify(error));
        });

We've noticed the platformResourceLoader loads our resources multiple times rather than checking if the resource is already loaded. This appears to be a shift away from how Aura handled it, which was a one time load.

See below for the script/link tags that appear multiple times when 2 components are on the page, or when we navigate between pages that have components on them.

Duplicate script/link tags for each component

Does this look like a bug or shift in how LWC handles this? If it's intended, is there a recommended way of checking the resource is loaded? For the time being we are loading the resources in a single component (in our footer) as a work around.

1 Answer 1

0

After much back and forth with Salesforce on this, it has been raised as a platform issue. You can follow the resolution of this at the following Known Issues link:

https://success.salesforce.com/issues_view?id=a1p3A000001YoFLQA0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.