The Vanilla JS Recommendation Widget project aims to create a versatile recommendation widget using the Taboola REST API. The widget displays both organic and sponsored recommendations, allowing users to interact with them seamlessly.
The primary goal was to design and implement a recommendation widget using Vanilla JavaScript. Leveraging the Taboola REST API, the widget fetches recommendations and presents them in an intuitive interface. The widget is responsive, functional, and easily extendable for future enhancements, such as adding new recommendation types.
The script needs to be implemented on the client's website, along with a designated <div>
element where the widget will be displayed. Here's how the implementation process works:
-
Placement of Script: The client embeds the script into their website. Upon loading, the script identifies the designated
<div>
element by its ID. -
Fetching Data: Once the website's DOM is loaded, the script triggers and fetches the recommendation data from the Taboola REST API.
-
Widget Creation: After retrieving the recommendation data, the script dynamically creates HTML elements for each recommendation.
-
Integration with Website DOM: Finally, the script integrates the recommendation widget into the client's website DOM, displaying it within the designated
<div>
element as specified by the client.
There are two folders for the project, one using Vite and the other without Vite.
- Clone the repository to your local machine.
- Open the project directory
recommendation-widget/recommendation-widget-non-vite
. - Open the
index.html
file in your browser to view the widget. - For testing, open
AppUnitTest.html
located inrecommendation-widget/recommendation-widget-non-vite/spec
in your browser.
- Clone the repository to your local machine.
- Open the project directory
recommendation-widget/recommendation-widget-vite/
in your preferred code editor. - Install dependencies by running
npm install
in the terminal. - Start the development server by running
npm run dev
, then navigate tohttp://localhost:5173/
. - For testing, run
npm test
and navigate tohttp://localhost:8888
.