List of commonly used libraries
The main location for our custom JavaScript files is lib/web/mage
, as shown:
Figure 11.1 – Location of custom JavaScript libraries
Some of the widgets can be created within the theme directory, or they can be defined in a module. As an example, the Magento_Ui
module comes with a lot of widgets that can be found in the vendor/magento/module-ui/view/base/web/js/
directory.
In the next few pages, I’ll show you three examples from the vast library of JavaScript widgets that are embedded in the platform.
Accordion widgets
Accordions are typically utilized to split up content into several segments that can be alternated, which helps conserve space on a page. To create an accordion widget, we simply call it using the following:
$("#element_id").accordion();
This widget does not require any configuration—just a proper HTML structure. We can call it using an imperative notation:
<...