Foundation CSS JavaScript Utilities Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Foundation JavaScript Utilities is a collection of tools that can be used to enhance the functionality of your Foundation website. To use Foundation JavaScript Utilities, you first need to include the foundation.js file in your website. Once you have done this, you can use the various utilities by calling the corresponding function. For example, to create a custom animation, you would use the Foundation.Move() function. SyntaxThe syntax for calling a Foundation JavaScript Utility function is as follows:Foundation.[Utility Name]([Arguments]); Selector EngineThe Foundation framework uses its own selector engine called "Big S". It is based on the native browser API querySelectorAll(), but it is optimized for performance. Foundation's Big S selector engine is about 20% faster than jQuery's selector engine.To use Foundation's Big S selector engine, you can use the s() function. For example, the following code would return a list of all the <div> elements with the class container:let element = s('.container');Throttle and DebounceThrottle and debounce are two techniques used to prevent a function from being called too often.Throttle: Throttling is a technique where you control the frequency of function execution. It ensures that the function doesn't execute more than once every X milliseconds.Debounce: Debouncing is a technique where you ensure that a function doesn't execute until after a certain amount of time has passed since it was called.In the Foundation framework, throttle and debounce are implemented using the Foundation.Throttle() and Foundation.Debounce() functions. The syntax for both functions is the same:Foundation.[Throttle/Debounce](functionToThrottleOrDebounce, waitTime, [callback]);Data OptionsData Options allow you to customize the behavior of certain Foundation components and plugins directly from the HTML markup.To use data options, you add data attributes to the element that you want to configure. The data attributes have the following format:data-[plugin-name]-[option-name]="[value]"Media QueriesMedia queries in the Foundation framework are used to change the behavior of Foundation components based on the size of the viewport. They are typically used to change the layout of a component or to add or remove functionality.To use media queries, you add media queries to the CSS rules that you want to apply to a Foundation component. The media queries have the following format:@media [media query] { [CSS rules]}Example 1: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Foundation JS Utilities Example</title> <link rel="stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/css/foundation.min.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="top-bar"> <div class="top-bar-left"> <ul class="dropdown menu" data-dropdown-menu> <li class="menu-text">GeeksForGeeks</li> <li> <a href="#">Courses</a> </li> <li> <a href="#">Tutorials</a> <ul class="menu"> <li><a href="#"> Data Structure and Algorithm </a></li> <li><a href="#">System Design</a></li> <li><a href="#">Web Development</a></li> </ul> </li> <li> <a href="#">Jobs</a> <ul class="menu"> <li><a href="#">For Job Seekers</a></li> <li><a href="#">For Recruiters</a></li> </ul> </li> <li> <a href="#">Contact</a> </li> </ul> </div> </div> <script src= "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"> </script> <script src= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/js/foundation.min.js"> </script> <script src="script.js"></script> </body> </html> CSS .top-bar, .top-bar ul { background-color: white; } .menu{ color: green; } a,ul,li{ color: black; } a:hover{ color: green; } ul:hover{ color: green; } li:hover{ color: green; } JavaScript $(document).foundation(); In this example, we have included the Foundation CSS file using the CDN link provided, and the necessary JavaScript files for jQuery and Foundation. We have also added the required markup for a top bar navigation menu with a dropdown submenu.To ensure the Foundation JavaScript utilities work correctly, we have included the jQuery library before the Foundation JavaScript file. Finally, we have initialized the Foundation framework by calling $(document).foundation().Output: Example 2: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <link rel="stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/css/foundation.min.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>GeeksForGeeks</h1> <p>Best Programming Languages</p> <ul class="accordion" data-accordion> <li class="accordion-item" data-accordion-item> <a href="#" class="accordion-title">Java</a> <div class="accordion-content" data-tab-content> Java is a high-level, class-based, object-oriented programming language that is designed to have asfew implementation dependencies as possible. </div> </li> <li class="accordion-item" data-accordion-item> <a href="#" class="accordion-title">Python</a> <div class="accordion-content" data-tab-content> Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation via the off-side rule. </div> </li> <li class="accordion-item" data-accordion-item> <a href="#" class="accordion-title">C++</a> <div class="accordion-content" data-tab-content> C++ was designed with systems programming and embedded, resource-constrained software and large systems in mind, with performance, efficiency, and flexibility of use as its design highlights. </div> </li> </ul> </div> <script src= "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"> </script> <script src= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/js/vendor/what-input.min.js"> </script> <script src= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/js/foundation.min.js"> </script> <script src="script.js"></script> </body> </html> CSS .container { margin: 20px; } h1 { color: green; } JavaScript $(document).foundation(); This example demonstrates the basic usage of the Foundation's accordion component. The example uses the Foundation CSS framework for styling and the Foundation JavaScript files to initialize the accordion functionality.Output: Reference: https://get.foundation/sites/docs/javascript-utilities.html. Comment More infoAdvertise with us Next Article Foundation CSS JavaScript Utilities P pranay0911 Follow Improve Article Tags : Web Technologies CSS Foundation Foundation-Setup Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Steady State Response In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We 9 min read JavaScript Interview Questions and Answers JavaScript (JS) is the most popular lightweight, scripting, and interpreted programming language. JavaScript is well-known as a scripting language for web pages, mobile apps, web servers, and many other platforms. Both front-end and back-end developers need to have a strong command of JavaScript, as 15+ min read React Tutorial React is a JavaScript Library known for front-end development (or user interface). It is popular due to its component-based architecture, Single Page Applications (SPAs), and Virtual DOM for building web applications that are fast, efficient, and scalable.Applications are built using reusable compon 8 min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Like