A js helper package


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @area17/a17-helpers in KB


A17 JS Helpers

A17 JS Helpers with an ES module pattern.



A collection of documented vanilla JS widgets.

In the A17 Boilerplate, we use these as a dependency and install via NPM. Alternatively you can copy the src folder and the index.js into a folder of your project and compile.

If installed via NPM, you'll want to import into your JavaScript by:

import helpers from '@area17/a17-helpers'

or, cherry pick individual helpers:

import { getCurrentMediaQuery, resized } from '@area17/a17-helpers'

If your project as Babel or any Javascript compiler, for smaller builds you should import helpers individually:

import ios100vhFix from '@area17/a17-helpers/src/utility/ios100vhFix'


From v2.0.0 onwards drops IE11 support but maintains Safari 10+, Edge 12+, Chrome 24+ and FireFox 29+ support. If you need IE11 support use v1.0.3 and if you need IE9 level support, use v0.8.4.


Feel free to add any vanilla JS helpers that will be common to many projects and save someone some time working them out in the future. The main aims are no dependencies, small elegant code and high potential sharing across sites.

Please make sure you run npm run prod after making changes. This will compile all your changes to ES5 ready version and then you can feel free to publish to npm.


Download the editor config plugin for your text editor: http://editorconfig.org/#download


Written using Mochajs and Chai.js, currently living in test/test.js. To run:

$ npm run prod
$ npm run test

TODO convert tests from pre-open-source Helpers to this version

To add/update a helper

  • Make your changes
  • Bump the version number
  • Test it, you may need to update the tests in /test/
  • Update the wiki document for it if required
  • Tell engineering-fe Slack room
  • Have a 🍦

Update Log


  • Update Production bundle


  • queryStringHandler : dont replace plus signs from query strings


  • store.js add better comment on this utility


  • store.js add new tiny library to help you manage state across your application. Inspired by great libraries like Vuex and Redux and based on Beedle. For more informations, see demo : http://bp7store.dev.area17.com/


  • resized helper updated to capture current media query being ""


  • updates isBreakpoint breakpoints to use shorthand breakpoint names: 'xs', 'md', 'lg', 'xl', 'xxl' (in line with A17 boilerplate 7.1.0 and A17 Tailwind plugins)


  • removes deprecated and useless utilities:
    • forEach gone (just use native forEach)
    • scrollToY (just use native with options)
    • triggerCustomEvent (use native: node.dispatchEvent(new CustomEvent('event:name', { detail: { foo: 'bar' } }));)
  • adds:
    • ios100vhFix - adds a --1vh CSS var to the :root for CSS usage to counter iOS frustrating 100vh change when the browser chrome disappears
    • responsiveImageUpdate - updates image sizes attribute on resized to make Safari recalc which source to use from the srcset
    • manageBehaviors and createBehavior from the boilerplate to create and manage behaviors, this version has the initial data bindings development
  • updates to:
    • setFocusOnTarget
    • resized to sends breakpoint info on resized and sets current media query on load
    • getCurrentMediaQuery reads breakpoint info from a CSS variable --breakpoint
    • focusTrap gets cleaned up
    • ajaxRequest can now send JSON forms


  • query string character replacement updated in .fromObject() in queryStringHandler to match fixedEncodeURIComponent at MDN:encodeURIComponent


  • resized sends its event to the window and not the document for backwards compatibility


  • Deprecated helpers are no longer used inside other helpers. If you're using scrolled you'll need to read event.detail.last and event.detail.prev (and not event.data.xxxx)


  • Support is IE11+, Safari 10+, Edge, recent Chrome, recent FF to bring into line with A17 FE Boilerplate (and no longer IE9+, Safari 6+).
  • Deprecation notices on:
    • forEach
    • manageBehaviors
    • triggerCustomEvent


  • Added scrolled - a custom event to track requestAnimationFrame limited scroll events


  • Fix focusTrap incorrectly removing events


  • Update compiled version


  • Added focusTrap and focusDisplayHandler to the index.js so this can be imported into your app


  • Added focusTrap and focusDisplayHandler to trap keyboard tab focus within an element and to help style keyboard focus states


  • ajaxRequest returns the request so you can abort it in your project function


  • Scroll to Y : call the onComplete callback even if not scrolling


  • Add rollup.js for compile the package. Now Everything is compiled. (Don't forget to compile it then push npm if you are updating it)


  • Added isBreakpoint helper to query if a breakpoint is active

0.6.6 and 0.6.7

  • Updated copyTextToClipboard as recent browser updates stopped it working


  • Updated lazyLoad to v2.1.1 inline with updates to that lib


  • Updated package-lock.json

0.6.2 and 0.6.3

  • Updated lazyLoad to init correctly


  • Updated lazyLoad to v2.1.0 inline with updates to that lib


  • Links to Wiki updated
  • Missing semicolons on imports added
  • Files with tabs as spaces converted to spaces for spaces
  • Added .editorconfig
  • Alphabetised index.js


  • Renamed message to messages, updated message--hide to s-hide


  • Added fontLoadObserver


  • Refactored debounce


  • Added default success message to copyTextToClipboard



  • Updated manageBehaviors to not have warning typo...


  • Updated manageBehaviors to warn when behavior fails to init and not trap JS errors from inside a behavior


  • Added forEach to loop querySelectorAll nodes


  • getOffset returns a full fixed getBoundingClientRect output (position with scroll) so includes bottom, right, width and height now


  • resized checks for and sets window.A17.currentMediaQuery when media query changes


  • Added jsdom an jsdom-global (https://github.com/rstacruz/jsdom-global) to devDependencies to test DOM events in Mocha tests.
  • Added .updateParameter() method to queryStringHandler helper Wiki
  • Added new setFocusOnTarget helper Wiki (with test)
  • Added new copyTextToClipboard helper Wiki (no test, not sure how to test..)


  • Merge turnObjectToQueryString and turnQueryStringToObject into queryStringHandler as .toObject() and .fromObject() methods
  • Add new debounce helper Wiki


Changed dependencies from a17.helpers format to module


Add all the helpers from original version


Basic structure and testing function

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.