1. Import the gifa11y.js library into the document.
<script src="gifa11y.umd.min.js"></script>
2. Initialize the Gifa11y library and specify the container element that holds your GIFs.
var gifa11y = new Gifa11y({
container: '.container'
}); 3. That’s it. The library will automatically add play/pause buttons to the GIFs inside the ‘container’.
4. Auto pause the GIF on initial load. When enabled, the library generates a preview image from the GIF’s first frame using HTML canvas.
<img loading="lazy"
src="demo.gif"
class="gifa11y-paused"
alt="Example GIF"
> 5. Ignore specified GIFs using the ‘gifa11y-ignore’ class.
<img loading="lazy"
src="demo.gif"
class="gifa11y-ignore"
alt="Example GIF"
> 6. Available options.
var gifa11y = new Gifa11y({
// Button styles
buttonBackground: 'indigo',
buttonBackgroundHover: 'rebeccapurple',
buttonBorder: '2px solid #fff',
buttonIconColor: 'white',
buttonFocusColor: '#00e7ffad',
buttonSvgSize: '1.5rem',
buttonIconFontSize: '1rem',
buttonPlayIconID: ' ',
buttonPauseIconID: ' ',
buttonPlayIconHTML: ' ',
buttonPauseIconHTML: ' ',
// Container
container: 'body',
// Ignore specific GIFs or regions
exclusions: '',
// Ignore specific containers
gifa11yOff: '.gifa11y-off',
// Inherit classes
inheritClasses: true,
// Pause GIFs on initial load
initiallyPaused: false,
// Warn content author if they are missing an alt attribute on GIF
missingAltWarning: true,
// Pausing any gif pauses all gifs.
sharedPauseButton: false,
// Show or hide Play/Pause buttons.
showButtons: true,
// Show or hide GIF text within buttons
showGifText: false,
// Using CSS selectors to target other images
target: '',
// i18n
langPause: 'Pause animation:',
langPlay: 'Play animation:',
langPauseAllButton: 'Pause all animations',
langPlayAllButton: 'Play all animations',
langMissingAlt: 'Missing image description.',
langAltWarning: '⚠ Error! Please add alternative text to GIF.',
}); 7. Create a button to play/pause all GIFs.
<button id="gifa11y-all">Pause/Play All GIFs</button>
8. API methods.
// Programmatically play/pause Gifa11y. window.gifa11y.setAll(myOtherAnimationsPlaying ? 'playing' : 'paused'); // Find new GIFs window.gifa11y.findNew();
v2.2.0 (05/16/2025)
v2.1.0 (01/28/2025)
v2.0.4 (11/20/2024)
v2.0.3 (01/08/2024)
v2.0.2 (06/14/2023)
v1.0.6 (08/23/2022)
07/01/2022
01/08/2022
12/14/2021
The post Accessible GIF Image Player In Vanilla JavaScript – Gifa11y appeared first on CSS Script.
So, Nvidia just revealed DLSS 5, its new AI graphics tech that uses generative systems…
Embark Studios, the dev behind Arc Raiders and The Finals has "mutually agreed to part…
Timothée Chalamet has shared a first-look image of Paul Atreides alongside a collection of character…
Introducing seasons in Forza Horizon 4 was a huge shift for the series. Bringing Britain…
Phishing attackers have found a way to turn a standard security feature against the very…
Through lectures, scoldings and outright threats, President Donald Trump and his aides are ratcheting up…
This website uses cookies.