Lightweight JavaScript Accordion Menu (Only 1KB)

This is a lightweight (only 1kb), accordion type JavaScript horizontal menu that does not require any JavaScript frameworks.

It is very easy to setup as the script automatically adjusts to the number of elements in the accordion and the dimensions of the accordion.

Accordion JavaScript Menu

How it works?

  • Create an unordered list like this:

<ul id="sm" class="sm">
<li><img src="images/1.gif" alt="" /></li>
<li><img src="images/2.gif" alt="" /></li>
<li><img src="images/3.gif" alt="" /></li>
<li><img src="images/4.gif" alt="" /></li>

  • Call the function below onload'sm',200,10,10,1)">

  • That’s all.


  • First: id of the unordered list
  • Second: width of the accordion
  • Third: timeout variable to control how quickly the sliding function is called
  • Fourth: speed of the accordion with 1 being the fastest
  • Fifth: is the integer that corresponds to the section you would like to be expanded when the accordion is loaded (optional)