html - Loading image using CSS animation VS loading using GIF image -
i encounter problem showing loading css animation while doing heavy javascript operation, wondering if css animation taking more resources showing simple loading gif image, made following tests.
1 created page loading css
- created page loading css animation
- created page loading gif image
- compared resources using chrome task manager
here results:
it looks css animation using more cpu, , more memory want consult using css animations. isn't heavy? should avoid using in loading cases?
loading example using css animation
loading example using gif image

here code loading css animation
css
/* beautiful loading screen */ #loadingwrap{ width: 100%; height: 100%; top: 0px; z-index: 250; background-color: rgba(255, 255, 255, 0.46); } .glyphicon.spin { font-size: 36px; -webkit-animation: spin 1.822s infinite linear; -moz-animation: spin 1.822s infinite linear; -o-animation: spin 1.822s infinite linear; animation: spin 1.822s infinite linear; -webkit-transform-origin: 50% 58%; transform-origin:50% 58%; -ms-transform-origin:50% 58%; /* ie 9 */ line-height: 0px; } @-moz-keyframes spin { { -moz-transform: rotate(0deg); } { -moz-transform: rotate(360deg); } } @-webkit-keyframes spin { {-webkit-transform: rotate(0deg);} {-webkit-transform: rotate(360deg);} } @keyframes spin { { transform: rotate(0deg); } {transform: rotate(360deg); } } #loadingicon { z-index: 10; position: absolute; right: 20px; bottom: 20px; line-height: 0px; } html
<div id="loadingwrap"> <div id="loadingicon"> <i class="glyphicon glyphicon glyphicon-cog spin">q</i> </div> </div> here code loading using simple gif image
css
#loadingwrap{ width: 100%; height: 100%; top: 0px; z-index: 250; background-color: rgba(255, 255, 255, 0.46); } #loadingicon { z-index: 10; position: absolute; right: 20px; bottom: 20px; line-height: 0px; background: url(../1-0.gif) no-repeat center center; width: 20px; height: 20px; } html
<div id="loadingwrap"> <div id="loadingicon"> </div> </div>
gif images:
positives
- performance (small file size)
- ease of use & setup
- older browser support
negatives:
- don't scale smoothly (retina displays, larger images)
- image quality(256 color limit)
- difficult adaptation & change (need specialized software photoshop)
css animations:
positives:
- easily editable through css
- high quality images , rich colors possible
- smooth scaling (retina ready images & svgs)
negatives:
- performance
- css animations not supported ie 7,8,9
- more complex setup
Comments
Post a Comment