Archive for July, 2011

jQuery.data vs jQuery.fn.data performance

July 9th, 2011

jQuery.data( element,key,value )
“Store arbitrary data associated with the specified element. Returns the value that was set”
.data( key,value )
“Store arbitrary data associated with the matched elements.”
Performance difference: on this jsPerf test the last is about 84% slower.
So instead of:
$(’#element’).data(’type’, ‘critical’)
prefer:
jQuery.data(’#element’, ‘type’, ‘critical’)
(tested on Google Chrome 12.0.742 browser)


on client-side Cache, Sinatra and Conditional GET’s

July 1st, 2011

After re-reading Google Code - Page Speed - Optimize Caching section, I began implementing it on the Sinatra app part of our eClinic.Pro system. Later, after having it working, I found out that Sinatra has this amazing helper:

# File ‘lib/sinatra/base.rb’, line 290
def last_modified(time)
  return unless time
  time = time_for time
  response[’Last-Modified’] = time.httpdate
  # compare based on seconds since […]