I apologize in advance for this report being a bit complicated (I'm not sure how to simplify the reproduction of the problem).
Problem
When Angular CLI (ng serve) generates an index.html file with:
<script src="vendor.js" defer>
instead of generating it with:
<script src="vendor.js" type="module">
Grid.showSpinner will often fail to display the spinner.
Setup
I've created a
stackblitz project to demonstrate the problem, *
but* please note that you must download the project and run it locally to see the problem.
Download the project from stackblitz, unzip, run "npm install", and then invoke the *local* ng with "./node_modules/.bin/ng serve".
Code/Behavior
When the browser loads the app, remote data is loaded into the Grid.
In ngAfterViewInit, a timer is set which waits for 2 seconds and then loads *more* remote data into the grid.
The remote data loading Observable also contains a 2 second delay before it responds with the requested remote data.
Working Scenario
When you refresh the web page, you will see a grid with data.
After 2 seconds, the spinner will appear (for another 2 seconds), and then the grid will redraw with the next 10 records that have been retrieved.
This will work perfectly every time.
Further, if you inspect index.html, you will notice that it loads all the js files with type="module".
e.g. <script src="vendor.js" type="module">
Failing Scenario
Now stop 'ng', and then edit the ".browserslistrc" file to support only the last *4* versions of Safari (the stackblizt ".browserslistrc" is initially set to support the last *5* versions of Safari).
Now re-run "./node_modules/.bin/ng serve", and again refresh the browser page.
You will see that the spinner does *not* shows after most page loads (although it will show about every 4th or 5th page load on my machine).
You will also note that because ".browserslistrc" specifies only the last 4 versions of Safari, that index.html now loads all the js files with "defer".
e.g. <script src="vendor.js" defer>
Explanation
Safari 10 did not support loading js modules. So by including an old browser like Safari 10, Angular CLI generates an index.html file with <script src="vendor.js" type="module">, but when you drop the older Safari 10, Angluar CLI generates an index.html file with <script src="vendor.js" defer> (this seems backwards to me, but that is another story).
Also please note that I am doing all this testing with Chrome 87, so the problem is not with Safari. I'm simply using the fact that Safari 10 did not support modules in order to control how Angular CLI generates the index.html file.
Summary
The important point of this report is that when Syncfusion spinner is loaded via type="module", it always works correctly.
But, when it is loaded via "defer", it frequently fails.
As more and more developers configure ".browserslistrc" to only support newer browsers, this will become an increasingly common problem for the Syncfusion spinner.
Just for completeness, I've also attached a zip of the stackblitz project.
P.S.
If the script is loaded via defer (which fails to show the spinner), you can then disable Chrome's cache (in the Developer Tools > Network tab), and the spinner will reliably show every time when you refresh the page.
This fact plus the type=module vs defer scenarios suggests to me that there is something in the Spinner code that is dependent on code execution ordering.
Attachment:
angularivy7koogw_2ec17b3c.zip