This week’s usual “Friday short post” about using jQuery in handheld devices. If you are a developer who is using jQuery in applications that were developed for use in environments with small processing power such as handheld devices, mobile phones, PDA’s, etc. you will find this post useful.
Anyway, back to the topic. For whatever reasons you chose to use jQuery in your application (I would suggest using plain javascript for better performance) jQuery effects such as animation, hide and show, etc. most likely were probably one of the reasons. Unfortunately, jQuery effects are process intensive and in “slow” environments it is recommended to turn them off. Fortunately, jQuery provides you with such a method. It lets you disable all animations and effects by changing jQuery.fx.off
setting to true
.
// Dissable all effects jQuery.fx.off = true; // Shorthand $.fx.off = true;
Now all your effects such as fadeIn()
, fadeOut()
, slideDown()
, slideUp()
, etc. will not be animated. They will simply be hidden and shown immediately (by changing CSS rules display:none;
display:block;
) to save CPU processing time.
NOTE:
By setting the jQuery.fx.off
back to false
you enable all animations and effects.
It's helpful.
ReplyDeleteThanks!
enjoy :)
If you're developing for mobile devices that use webkit browswers (iPhone, Pre, G1) you can use webkit animations instead of javascript. On the iPhone webkit animations are handled by the hardware and not software.
ReplyDelete@nanoremix, good point.
ReplyDeletehey, this is quite useful stuff! i am new to jquery, but i will surely use this in the private project i am working on. so, thumbs up and big thanks!
ReplyDelete