BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

[OC] Downsize the webchat script hosted on CDN

Open charliewang95 opened this issue 4 years ago • 4 comments

Please view our Technical Support Guide before filing a new issue.

Feature Request

Use the 'feature-request' query to search for existing feature requests.

The Samples tag also lists examples and implementations that have already been requested.

Is your feature request related to a problem? Please describe.

Customer of Dynamics 365 Omnichannel reported that because webchat script is too large (~5MB full size), their Google Lighthouse score dropped and their website is ranked lower than before in Google search engine.

Other incidents report that failure to load webchat script

Describe the suggestion or request in detail

Decrease the size of said script (We're using webchat-es5.js for instance).

Describe alternatives you have considered

Provide different versions of webchat leaving certain features out as the customer sees fit (For example, OC doesn't need speech), so it might be beneficial to use a version that doesn't have speech modules

Additional context

Unused JS Treemap

[feature-request]

charliewang95 avatar Aug 26 '21 00:08 charliewang95

Discussed with @charliewang95. I believe this will be a collaborative work and need improvements on both side.

This is partly because Lighthouse seems only look at data from the first page load. That means, if Adaptive Cards or Speech code is later used when Web Chat is triggered, Lighthouse couldn't capture those instrumentation data and will consider AC and Speech as unused code.

compulim avatar Aug 26 '21 03:08 compulim

The solution that worked for me is to show a lightweight chat-button in stead of loading the whole application on page-load.

HesselWellema avatar Dec 08 '21 10:12 HesselWellema

I experimented with ESBuild and the bundle size did not go down. Instead, it goes up for 20%.

We should look at the number of these scenarios to see how good we are doing treeshaking. All of these scenarios are based on NPM.

  • Did not use Web Speech or Cognitive Services
  • Did not use DL ASE

Maybe we should also add tests to look at meta.json to make sure when certain components are not used, they are not built into the bundle.

compulim avatar Jun 28 '22 18:06 compulim

Sent out a request to do tree shaking on speech

charliewang95 avatar Aug 04 '22 21:08 charliewang95