2.1 (42.07%) 29 votes

Hello everyone. Loader is very useful for you when you make some Ajax request. It is very important when you develop a website.

In Magento 2, it provide you a Loader widget Javascript. So you can call it for your purpose.

You can define ‘mage/loader’ in your js to call the widget.

The loader widget has the following options:

  • icon
  • template
  • texts

Loader Widget in Magento 2

1, Icon:

The URL to the loader image. This image is displayed when the widget is active; that is, between the ajaxSend and ajaxComplete events.

  • Type: String
  • Default value: No image by default.

2, Template

HTML wrapper for the output, or a DOM element selector.

Default value:

3, Texts

An object that contains translations for loader text:

texts.loaderText: The text that is displayed under the loader image.

  • Default value: ‘Please wait…’

texts.imgAlt: The text that is set as the alt attribute value of the loader image.

  • Default value: ‘Loading…’

Events

  • processStart: Display the loader. Can be triggered on any page element.
  • processStop: Hide the loader. Can be triggered on any page element.

The steps I mention above is the shortest process for you to Loader Widget in Magento 2 . With this guide, you can manage the Loader Widget in Magento 2 easily. Every store has a Loader Widget in Magento 2 with many attributes.

Thank you for reading this post and see you in other posts from Magestore!

Magento 2 – Debug in Command Line Mode
How to Fix Issue "No Region Found within the Locale..." in Magento 2