Optimizing JQuery based animation by caching selector result? -
i've made animation who's based on following jquery functions : hide(), show(), animate().
this animation consumes lot of cpu (the flash cpu usage), chrome tells me (through css selector profiling tool) i've lot of similar css selectors usage (css selector profile).
does these selectors used rendering engine ? include jquery node search while using $() (i assumed it's called hide(), show() or animate()) ?
if yes second question, how override function cache node ? (by hard coding few selectors result won't change in animation logics).
edit : i'm implementing transition between frames, each frame ken burns effect on background
edit2 : here's jquery plugin use css3 animation when possible https://github.com/benbarnett/jquery-animate-enhanced
if doing alot of jquery animations using code following:
$('div.myclass').show(); ... $('div.myclass').hide(); .... $('div.myclass').toggle(); you might want @ chaining jquery selections:
$('div.myclass').show().addclass('sdf').children('li').slidetoggle() or assigning selector variable , reusing variable
var $ele = $('div.myclass'); $ele.show(); ... $ele.hide(); .... $ele.toggle();
Comments
Post a Comment