Repeating DOM elements without loading Vue or React

1 minute read

Repeating DOM elements without loading Vue or React

data-repeat is a minimal JavaScript package that lets you repeat an element a specified number of times using the data-repeat attribute. This is especially useful in test cases or when working with libraries like TailwindCSS for quick prototyping.

How to Use data-repeat

Add the following script to your HTML:

<script src="https://unpkg.com/data-repeat"></script>

Add the data-repeat attribute.

Simply add the data-repeat attribute to an element, specifying the number of repetitions. For example, to repeat an element five times:

<button data-repeat="5">Click me</button>

Why Use data-repeat?

Simple and Lightweight: No need for frameworks like Vue or React.

  • Fast and Easy: Just add the data-repeat attribute with the desired number of repetitions.

  • Perfect for Testing and TailwindCSS: Great for quick DOM manipulations in small projects or test scenarios.

  • With data-repeat, repeating elements becomes straightforward and efficient, saving you the hassle of heavier libraries.