VOOZH about

URL: https://www.geeksforgeeks.org/css/foundation-css-javascript-installation-initialization/

⇱ Foundation CSS JavaScript Installation & Initialization - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Foundation CSS JavaScript Installation & Initialization

Last Updated : 7 Mar, 2022

Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is built on Saas-like bootstrap. It is more sophisticated, flexible, and easily customizable. It also comes with CLI, so it’s easy to use it with module bundlers. It offers the Fastclick.js tool for faster rendering on mobile devices.  

JavaScript Installation:

 We can add Foundation CSS JavaScript to our webpage in 2 ways:

  • Using NPM Install
  • Using CDN Link

We will understand both the ways of using Javascript in Foundation CSS, along with their implementations.

Using NPM Install:

Foundation is available on npm. This package includes all of the source Sass and JavaScript files, as well as compiled CSS and JavaScript, in uncompressed and compressed flavors.

npm install foundation-sites

Using CDN Link:

We can get the required foundation JS from CDN by just inserting the below lines of code in our HTML template:

<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"> </script>

JavaScript Initialization:

The .foundation() function on the jQuery object, can be utilized to avail every Foundation plugin at once.

Syntax:

$(document).foundation();

Example: This example shows the significance of Foundation JS by implementing it & without implementing it.

Using JS Installation and Initialization:

Output:

πŸ‘ Image
With JavaScript installation in Foundation CSS
  • Without Foundation JS Installation and Initialization:

Output: From the output, we haven't used the Foundation CSS JavaScript, so the code does not work intended.

πŸ‘ Image
Without Foundation JS Installation 

Reference: https://get.foundation/sites/docs/javascript.html#installing

Comment
Article Tags: