Javascript from fragments is included in HTML Page using SCRIPT
-
What changed?
Javascript from fragments is now included in the page using a<script>of type module, instead of embedding the code in a function -
Why was this change made?
We wanted to leverage all the features available in the javascript modules: JavaScript modules - JavaScript | MDN
For example: the ability to use import statements -
What is affected?
Code that is not supported directly in a<script>tag of type module
For example:returnstatements outside the scope of a function- Automatic variable declaration, for example
myVariable = 'value'
-
How should I update my features or implementation to better adopt the breaking change?
Code should be fairly easy to migrate, just remove any return statement, and for the variable declaration you either useletorconstnext to the variable nameconst myVariable = 'value'
As a temporary workaround (would be removed soon), we have added disable to this feature. You have to go to Instance Settings -> Page Fragments -> Fragment Javascript and disable the checkbox