Fitty

Fitty, Snugly text resizing

Scales up (or down) text so it fits perfectly to its parent container. Ideal for flexible and responsive websites.

  1. First you have to make a child theme of your current theme.
  2. Then, in your child theme create a functions.php file
  3. Create a js folder and put fitty.min.js inside it and create a child.js file also inside this js folder
  4. In functions.php of your child theme add the following :
<?php // Opening PHP tag - nothing should be before this, not even whitespace
function child_scripts() {

    wp_enqueue_script( 'fitty', get_theme_file_uri( '/js/fitty.min.js' ), array(), filemtime( get_theme_file_path( '/js/fitty.min.js' ) ), true );

    wp_enqueue_script( 'child', get_theme_file_uri( '/js/child.js' ), array( 'jquery' ), filemtime( get_theme_file_path( '/js/child.js' ) ), true );

}
add_action( 'wp_enqueue_scripts', 'child_scripts' );

In child.js add the following :

(function ($) {

    fitty('#my-element'); // Here fitty is targeting the element with an id='my-element' 

})(jQuery);