Last Updated: February 25, 2016
·
3.35K
· 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>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside