CSS spinner with javascript
... conclusions ...
- Repeat in Firefox/Chrome (empty cache / hard reload): Ctrl + Shift + R; in IE-11: Ctrl + F5; see
cache-test for more.
Conclusions
- While the used construction of spinner and javascript is made in a progressive enhancement way, all kinds of visitors/devices are served (as far as I can see).
- A text-only browser (and the Google-bot) doesn't see the spinner (nor the images): no problem.
- If CSS is disabled, there is no spinner and the spinner-script is inoperative; images will appear as soon as they are downloaded.
- If CSS is enabled and Javascript disabled, then fast loaded images and missing images don't have a spinner; only slow loading images get a spinner.
- If CSS and Javascript are both enabled, then that's the same and the visitor can enjoy a smooth fade-in of slow loaded images.
- The spinner CSS styles are small (3.5kB uncompressed), the spinner javascript too (1.5kB uncompressed). They can be minified and included in existing
stylesheets and javascript-files; then they don't need an extra http-request.
- The CSS-validator and HTML-validator can appreciate the code.
- Testing on a pc (Win-7) is positive for Firefox, Chrome, Opera en Internet Explorer-11. On mobile devices I couldn't test, but according to the simulations
in Firefox and Chrome Developer Tools I don't expect problems. The only thing is extremely small images, then the spinner could overflow the imgBox; but
small images are fast downloaded, and shouldn't need a spinner. Anyway, the Google's Mobile Friendly Test is satisfied.
- Google's PageSpeed Insights tell that the previous page has a speed score of 99 out of 100 according to the Lighthouse lab data. More about this
on the next page .
And of course the are lots of ways to refine these basic ideas.
So far, so good.
All well and good - but, but, but ...
"On my PC I don't see any spinner in the imgBoxes on this page!"
True - and all HTML, CSS and javascript is exactly the same as on the previous page...
"Why does the 'empty cache / hard reload' not work any more?"
Has the spinner evaporated in the cloud?
The mystery