Last Updated: February 25, 2016
·
2.958K
· mindeavor

Lazy-loading tooltips (twitter bootstrap)

A simple way to reduce load time by waiting to load tooltips until they're needed:

$(document).on('mouseover', '.tip', function () {
  if ( $(this).data('isTooltipLoaded') == true ) { return; }
  $(this).data('isTooltipLoaded', true).tooltip().trigger('mouseover');
});

Example html:

<p>This required a <span class="tip" title="A premium account is...">premium</span> account.</p>