Computer Science  ·  Level 6
Web Designing
Chapter 8: JavaScript libraries
📚 7 Topics
⚑ What you will be able to do

By the end of this chapter, you will be able to:

  • Confidently apply the concepts of JavaScript libraries in your web projects.
  • Use the JQuery framework to boost your website’s functionality.
  • Correctly install JQuery by following the proper procedures.
  • Reference JQuery properly in your web projects for smooth operation.
  • Accurately use JQuery syntax to manipulate web elements as needed.
  • Implement JQuery events correctly to make your web pages interactive and engaging.
  • Perform DOM manipulation using JQuery to update and manage web page content effectively.

Mastering these skills will help you create dynamic, user-friendly websites that stand out in the real world of web development.

8.1 Libraries concept

A JavaScript library is a collection of pre-written, tested JavaScript code that provides ready-made functions for common tasks, such as selecting page elements, handling events, animating content, making server requests or drawing charts. Instead of writing the same code from scratch on every project, a developer includes the library and calls its functions. Libraries save time, reduce errors and smooth over differences between browsers.

Example: the web developer for a hardware shop in Sotik used a chart library to show monthly cement and iron sheet sales on the owner's dashboard instead of coding the drawing logic by hand.

Library and framework compared

Feature Library Framework
Control Your code calls the library when needed The framework calls your code (inversion of control)
Scope Solves specific tasks Provides the whole structure of an application
Flexibility High, use only what you need Follows the framework's rules
Examples jQuery, Lodash, Chart.js, D3.js Angular, Vue, Next.js

React is usually described as a library for building user interfaces, although it is often used like a framework.

Benefits of using libraries

  • Faster development: common features are already written.
  • Cross-browser compatibility: the library handles browser differences.
  • Reliability: popular libraries are tested by many developers.
  • Shorter, cleaner code: one library call replaces many lines.
  • Community support: documentation, tutorials and plug-ins.

Drawbacks

  • Extra download size: slows page loading on slow connections.
  • Dependency risk: a library may stop being maintained or have security flaws.
  • Learning curve: each library has its own syntax.
  • Over-use: using a large library for a small task.

Common JavaScript libraries

  • jQuery: DOM selection, events, effects and AJAX.
  • Lodash: utilities for arrays, objects and strings.
  • Chart.js and D3.js: charts and data visualisation.
  • Axios: HTTP requests.
  • Moment.js and Day.js: dates and times (Moment.js is now in maintenance mode, Day.js is a lighter alternative).
  • Three.js: 3D graphics.

Ways of adding a library to a page

  • Content Delivery Network (CDN): link to a hosted copy with a script tag.
  • Local file: download the .js file and store it with the site.
  • Package manager: install with npm and bundle with tools such as Vite or webpack.

Choosing a library

  • Fit for the task: does it solve the actual problem?
  • Size: smaller is better for mobile users.
  • Maintenance: recent releases and active issue tracking.
  • Licence: most use MIT or similar open licences.
  • Documentation and community.
The rest of this chapter
🔒

Create a free account to open more of this chapter.

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒8.2 JQuery framework

jQuery is a fast, small, feature-rich JavaScript library, first released by John Resig in 2006, that makes it easy to select and change HTML elements, handle events, create animations and make AJAX calls with a simple syntax that works the same across browsers…

🔒8.3 Installation of JQuery

Installing jQuery means making the jQuery library file available to a web page. Because jQuery is a single JavaScript file, installation is simple: either download the file into the project, link to a copy on a content delivery network (CDN), or install it wit…

🔒8.4 Referencing JQuery

Referencing jQuery means linking the library to an HTML page with a script element so that the page's own code can use it. The reference must point to the correct file path or URL, appear before any script that uses jQuery, and the code that changes the page m…

🔒8.5 JQuery syntax

jQuery syntax is designed for selecting HTML elements and performing actions on them. The basic pattern is $(selector).action(), where $ (an alias for jQuery) creates a jQuery object, the selector finds elements, and the action is a method applied to every mat…

🔒8.6 JQuery events

An event is an action that the browser detects, such as a key press, a mouse click, a form submission or the page finishing loading. jQuery lets a developer attach handler functions to events with simple methods, mainly .on(), so that the page responds to the…

🔒8.7 DOM manipulation with JQuery

The Document Object Model (DOM) is the tree of objects the browser builds from an HTML page, in which every element, attribute and piece of text is a node. DOM manipulation means reading and changing this tree with code: changing content, attributes, classes a…

Chapter Practical Activities

Practical 1: Develop a web page using jQuery for dynamic DOM manipulation

Computer Science · Level 6
Web Designing
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Develop a web page named student_info.html that uses jQuery to capture and dynamically display student details within a 1024px by 768px viewport.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Computer with text editor and browserPlain paper
Internet access for jQuery CDN
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Computer with text editor and browser1 Pc per Candidate
2Internet access for jQuery CDN1 connection per Candidate
3Plain paper1 Sheet per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Setup and HTML form creation
Launched text editor and created student_info.html file
(Award 2 marks for correct file creation and launch)
2
Added HTML form with input fields: Student Number, Mathematics, Biology, Chemistry, Physics
(Award 1 mark per correctly implemented input field or zero)
6
Included input validation for numeric marks fields to reject non-numeric entries
(Award 1 mark each for validation on Mathematics, Biology, Chemistry, Physics)
4
Sub-Total12
TASK 2: jQuery implementation for calculations and DOM manipulation
Imported jQuery library via CDN correctly
(Award 2 marks for correct inclusion of jQuery script tag)
2
Implemented jQuery script to calculate sum of marks upon button click
(Award 2 marks for correct sum calculation logic)
2
Implemented jQuery script to calculate average of marks correctly
(Award 2 marks for correct average calculation logic)
2
Determined and displayed grade based on average using jQuery DOM manipulation
(Award 1 mark for correct grade logic, 1 mark for displaying grade)
2
Displayed all entered and calculated data dynamically on the web page using jQuery
(Award 4 marks for correct dynamic display of data)
4
Sub-Total12
TASK 3: User interface and styling
Added a descriptive heading to the web page
(Award 1 mark for appropriate heading)
1
Implemented a reset button to clear form and displayed data
(Award 2 marks for correct reset button functionality)
2
Applied basic CSS styling for center alignment and readability
(Award 3 marks for appropriate styling)
3
Sub-Total6
PRODUCT CHECKLIST
Web page file student_info.html exists and loads without errors
(Award 2 marks for file existence and error-free loading)
2
Form accepts and rejects inputs correctly (numeric validation enforced)
(Award 3 marks for input validation correctness)
3
Sum and average calculations are accurate with correct grade determination
(Award 5 marks for calculation accuracy and grade correctness)
5
Dynamic display updates correctly on input and button actions
(Award 3 marks for proper DOM manipulation and display)
3
User interface is neat, readable, and form resets properly
(Award 3 marks for UI neatness and reset functionality)
3
Sub-Total16
GRAND TOTAL46
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)

Practical 2: Develop a React.js Interactive To-Do List Application

Computer Science · Level 6
Web Designing
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Create a React.js to-do list application with add, delete, and toggle complete features displayed on a webpage of size approximately 800px width by auto height.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Functional Computer with Node.js and React.js InstalledReact.js library
Code Editor (e.g., VS Code)JavaScript ES6+
Internet Access for React.js DocumentationHTML5
CSS3
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Functional Computer with Node.js and React.js Installed1 Pc per Candidate
2Code Editor (e.g., VS Code)1 Pc per Candidate
3Internet Access for React.js Documentation1 Pc per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Setup React.js Project Environment
Launched code editor and initialized React project using create-react-app
(Award 3 marks for successful project setup or zero)
3
Created two functional components: ToDoInput and ToDoList
(Award 2 marks each component created or zero)
4
Implemented state management using React useState hook
(Award 4 marks for correct use of useState or zero)
4
Sub-Total11
TASK 2: Implement Interactive Features
Implemented add new to-do item functionality with input validation
(Award 5 marks for working add function or zero)
5
Implemented delete to-do item functionality with button click
(Award 5 marks for working delete function or zero)
5
Implemented toggle complete status with visual indication (e.g., strike-through)
(Award 5 marks for correct toggle and styling or zero)
5
Sub-Total15
TASK 3: User Interface and Styling
Applied CSS styling to center the application within an 800px wide container
(Award 3 marks for correct container styling or zero)
3
Added heading 'My To-Do List' with appropriate font size and alignment
(Award 2 marks for heading styling or zero)
2
Styled to-do items with clear visual cues for completed vs pending tasks
(Award 4 marks for distinct styling or zero)
4
Sub-Total9
PRODUCT CHECKLIST
To-do list application runs without errors and displays on a webpage approximately 800px wide
(Award 4 marks for functional application or zero)
4
Add, delete, and toggle complete features work correctly and update UI dynamically
(Award 6 marks for full feature functionality or zero)
6
UI is neatly styled with centered layout, heading, and item status clearly visible
(Award 5 marks for polished UI or zero)
5
Sub-Total15
GRAND TOTAL50
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)
🔒

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒Integrate Lodash library to filter and sort student scores arrayPractical 3
🔒Create a Web Page with Interactive D3.js Bar Chart for Sales DataPractical 4
🔒Develop a Web Page that Fetches and Displays Data Using AxiosPractical 5
🔒Implementing Moment.js for Date and Time Formatting in a Web PagePractical 6
🔒Develop an animated banner using GreenSock (GSAP) with specified dimensionsPractical 7
🔒Develop a Web Page Displaying Bar and Pie Charts Using Chart.jsPractical 8
🔒Implement form validation using Validator.js on a user registration formPractical 9
🔒Create Modular JavaScript Code Using RequireJS for Asynchronous LoadingPractical 10
Am I competent?

At the start of this chapter we promised you would be able to:

  • Confidently apply the concepts of JavaScript libraries in your web projects.
  • Use the JQuery framework to boost your website’s functionality.
  • Correctly install JQuery by following the proper procedures.
  • Reference JQuery properly in your web projects for smooth operation.
  • Accurately use JQuery syntax to manipulate web elements as needed.
  • Implement JQuery events correctly to make your web pages interactive and engaging.
  • Perform DOM manipulation using JQuery to update and manage web page content effectively.

Tick each one you can genuinely do.

So, are you there yet?

You're competent when you can confidently do 50% or more of what this chapter promised.

Sign in to record how you're doing.