Lightweight and flexible JavaScript modal library


Lightweight and flexible JavaScript modal library


  • The size is 3 kB (gzip), doesn’t need any dependencies. HystModal is written in pure JavaScript, does not require jQuery or other libraries to work
  • Carefully designed UX for ease of use. Prevent scrolling of the background, three ways to close the window, scroll bar tracking, centering the modal.
  • Full customizable by CSS. Styles of the modal window and background is completely determined in CSS. Based on Flexbox, modals can have any CSS transitions.
  • Without changing the DOM of page Modal opening is performed only by CSS. All custom event listeners on elements inside the modal will not stop working.
  • A11y and capture the focus. Designed with accessibility in mind and WAI-ARIA recommendations. When you opened the modal focus is captures inside.
  • Works in Internet Explorer 11. Works without problems in IE11 and all modern browsers. Don’t need any polyfills or transpiler.


  1. Download and unpack the latest version of hystModal

  2. Connect hystmodal.min.js and hystmodal.min.css from “dist” folder to the page:

    <link rel="stylesheet" href="hystmodal.min.css">
    <script src="hystmodal.min.js"></script>
  3. Put the following markup in your HTML document:

    <div class="hystmodal" id="myModal" aria-hidden="true">
        <div class="hystmodal__wrap">
            <div class="hystmodal__window" role="dialog" aria-modal="true">
                <button data-hystclose class="hystmodal__close">Close</button>  
                <!-- You modal HTML markup -->

.hystmodal - Main selector of the modal. It must have a unique id attribure. This selector don’t get focus when modal is closed, due CSS rules visbility:hidden. Attribute aria-hidden is switches automatically.

.hystmodal__wrap - scrolled area under the modal window. Due of settings, it can close modal window on click/tap. This selecor don’t have background by default. Selector .hystmodal__shadow, which obscures the page content is added automatically directly before closing tag, when the script is loaded.

.hystmodal__window - Modal box. WAI-ARIA recommends adding attribute aria-labelledby with descriptions of the modal for better accessibility.

[data-hystclose] - selector with data-hystclose attribute is closing current modal window on mouse click, if this set on in configuration. This selector may contains in any place inside .hystmodal__window

  1. Place following JS code for activating functionality of modals:

    const myModal = new HystModal({
        linkAttributeName: "data-hystmodal",
        //settings (optional). see Configuration
  2. Add attribute data-hystmodal on element that will be opening the modal window. Value of the attribute must be CSS selector (id or class name of the window). For example:

    <a href="#" data-hystmodal="#myModal">Open modal with id=myModal</a>

Title of data-attribute, which opening the modals, is defined by value of the property linkAttributeName of the configurations object.

  1. If necessary, change the сonfiguration.


Parameter Type Default Description
linkAttributeName String Empty string Define data-attribute of selector, which will be opening modal window on mouse click. Value of this attribute in HTML tag must be equal of CSS selector (id or class) of the modal window selector, which need to be open. If the property is not defined, event handlers will not be activated.
closeOnOverlay Boolean true Allow/disallow closing windows by click or tap on overlay (selector with class .hystmodal__wrap )
closeOnEsc Boolean true Allow/disallow closing windows by pressing ESC on the keyboard
closeOnButton Boolean true Allow/disallow closing windows by click on element with attribute data-hystclose. If there are multiple selectors with this attribute, modal window will closed by click on any of this
waitTransitions Boolean false If true – modal window will be closed after ending of CSS-transition of elements .hystmodal__window. If false – modal window will be closed instantly. So that the opening also took place instantly – delete CSS property transition of .hystmodal__window and set the option waitTransitions:false.
catchFocus Boolean true If true – when modal window is opened, focus will looped on active elements inside modal. When modal window closing, focus returning on previous selector.
fixedSelectors string “*[data-hystfixed]” Contains a css selector that adds an margin-right equal to the width of the scroll bar when opening a modal window. Useful for fixed elements on a page to avoid shifting them when opening a window. Works only if the property backscroll:true
backscroll boolean true If true - the scrolling will be blocked when the window is opened. If false, scrolling is not blocked (if the modal window is high, double scrolling may occur)
beforeOpen function Empty function Callback function. Run before opening of the modal. A modal window object (see API) is passed to the function as argument.
afterClose function Empty function Callback function. Run after closing of the modal. A modal window object (see API) of the closed window is passed to the function as argument.

Configuration example

const myModal = new HystModal({
    linkAttributeName: 'data-hystmodal',
    catchFocus: true,
    waitTransitions: true,
    closeOnEsc: false,
    beforeOpen: function(modal){
        console.log('Message before opening the modal');
        console.log(modal); //modal window object
    afterClose: function(modal){
        console.log('Message after modal has closed');
        console.log(modal); //modal window object


When creating an instance of a class HystModal by code new HystModal({ … }), variable myModal will contain object, which contain properties and methods.


Title Type Description
isOpened Boolean Modal open indicator. True - modal window is open in this moment. False - by default. Many private methods of the library are guided by the value of this property.
openedWindow DOM node Selector of current opened modal window. If window is closed - contain selector of last opened window.
starter DOM node Selector from which the modal window was opened. Used to return focus to an element.
config object Configuration object. See Configuration.


Title Description
init() Initializes the modal window functionality and enables event handling on the page. If the linkAttributeName property is specified, init runs automatically when an instance of the HystModal is created. You can specify the linkAttributeName:false when creating instance of the HystModal, and add property later (for example: myModal.config.linkAttributeName = ‘data-othermodal’). Then you must manually call the myModal.init(). Initialization can only do once.
open(selector) Open modal window. selector – a CSS selector of modal window as a string, for example:“#modal-1”). If «selector» is not specified – will open last opened window, or there will be no action. If opening new window while the old one is not closed, the previous window is closed first, and then a new window is opened.
close() Closes the currently open modal window.

Download Details:

Author: AddMoreScripts


Source Code:


What is GEEK

Buddha Community

Lightweight and flexible JavaScript modal library
CodingNepal .

CodingNepal .


Popup Share Modal UI Design using HTML CSS & JavaScript

#css share modal #modal dialog box #popup share modal #share modal #share modal in javascript

Rahul Jangid


What is JavaScript - Stackfindover - Blog

Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.

Who invented JavaScript?

JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.

What is JavaScript?

JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.

Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.

JavaScript Hello World Program

In JavaScript, ‘document.write‘ is used to represent a string on a browser.

<script type="text/javascript">
	document.write("Hello World!");

How to comment JavaScript code?

  • For single line comment in JavaScript we have to use // (double slashes)
  • For multiple line comments we have to use / * – – * /
<script type="text/javascript">

//single line comment

/* document.write("Hello"); */


Advantages and Disadvantages of JavaScript

#javascript #javascript code #javascript hello world #what is javascript #who invented javascript

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

It is said that a digital resource a business has must be interactive in nature, so the website or the business app should be interactive. How do you make the app interactive? With the use of JavaScript.

Does your business need an interactive website or app?

Hire Dedicated JavaScript Developer from WebClues Infotech as the developer we offer is highly skilled and expert in what they do. Our developers are collaborative in nature and work with complete transparency with the customers.

The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.

Get your business app with JavaScript

For more inquiry click here

Book Free Interview:

#hire dedicated javascript developers #hire javascript developers #top javascript developers for hire #hire javascript developer #hire a freelancer for javascript developer #hire the best javascript developers

Mya  Lynch

Mya Lynch


Top 5 JavaScript Libraries to Create an Organizational Chart

In this article, we’ll review five JavaScript libraries that allow you to create online organizational charts. To make this info useful for different categories of readers, we’ve gathered together libraries with different functionality and pricing policy. To help you decide whether one of them is worthy of your attention or not, we’ll take a look at the main features and check if the documentation is user-friendly.

DHTMLX Diagram Library

The DHTMLX diagram library allows creating easily configurable graphs for visualization of hierarchical data. Besides org charts, you can create almost any type of hierarchical diagrams. You can choose from organizational charts, flowcharts, block and network diagrams, decision trees, mind maps, UML Class diagrams, mixed diagrams, and any other types of diagrams. This variety of diagrams can be generated using a built-in set of shapes or with the help of custom shapes.

You can set up any diagram shape you need with text, icons, images, and any other custom content via templates in a few lines of code. All these parameters can be later changed from the UI via the sidebar options in the editor.

Top 9 JavaScript Charting Libraries

The edit mode gives an opportunity to make changes on-the-fly without messing with the source code. An interactive interface of the editor supports drag-and-drop and permits you to change each item of your diagram. You can drag diagram items with your mouse and set the size and position property of an item via the editor. The multiselection feature can help to speed up your work in the editor, as it enables you to manipulate several shapes.

The library has an exporting feature. You can export your diagram to a PDF, PNG, or JSON format. Zooming and scrolling options will be useful in case you work with diagrams containing a big number of items. There is also a search feature that helps you to quickly find the necessary shape and make your work with complex diagrams even more convenient by expanding and collapsing shapes when necessary. To show the structure of an organization compactly, you can use the vertical mode.

The documentation page will appeal both to beginners and experienced developers. A well-written beginner’s guide contains the source code with explanations. A bunch of guides will help with further configuration, so you’ll be able to create a diagram that better suits your needs. At the moment, there are three types of licenses available. The commercial license for the team of five or fewer developers costs $599, the enterprise license goes for $1299 per company, and the ultimate license has a price tag of $2899.

#javascript #web dev #data visualization #libraries #web app development #front end development #javascript libraries #org chart creator

Niraj Kafle


The essential JavaScript concepts that you should understand

As a JavaScript developer of any level, you need to understand its foundational concepts and some of the new ideas that help us developing code. In this article, we are going to review 16 basic concepts. So without further ado, let’s get to it.

#javascript-interview #javascript-development #javascript-fundamental #javascript #javascript-tips