A JavaScript library for randomizing taglines by substituting sentences for each other, swapping only the necessary words, substituteteacher.js is an easy way to be sure that your site’s users see different text whenever they visit — and is a great way to provide fresh descriptions and other information for photo and video content.
The script is simple, requiring the addition of the substituteteacher.js file, the creation of a container element and fallback text, and the script’s initialization. Text variables are stored in an array and easily accessed through an API, which provides control over the sub constructor, which creates a new instance of substitution using a list of sentence strings. Options include specifying a random substitution or using a specific order of text substitutions, as well as the interval and speed of the transitions. A run command lets the script run programmatically, or when a user clicks a button, to start the sentences’ rotation.