The Wayback Machine - https://web.archive.org/web/20241001002227/https://www.geeksforgeeks.org/building-basic-chrome-extension/
Open In App

Building a Basic Chrome Extension

Last Updated : 04 Mar, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Want to add extra functionality to your Chrome browser or create a useful tool? Developing a Chrome extension is a great starting point! In this tutorial, we’ll break down the essential steps of building your first basic (yet functional) extension.

So there’s some basic stuff that is required, it’s just like making a website, with a manifest!

  • HTML: The building block of all websites, a standard markup language which along with CSS and JavaScript is used by web developers to create websites, mobile user interfaces, and applications.
  • CSS: A style sheet language used to set the style for the HTML elements.
  • JavaScript: Commonly used to create interactive effects within web browsers.

JSON: JavaScript Object Notation, is an open standard format that uses human-readable text to transmit data objects consisting of attribute-value pairs. It is the primary data format used for asynchronous browser/server communication (AJAJ), largely replacing XML (used by AJAX).

A few Preliminaries: Chrome Extensions follow a specific directory structure. That means the filename is already fixed, they should be organized in a certain way as instructed.

Core Components of a Chrome Extension

  • manifest.json: The heart of your extension, defining metadata, permissions, and content interaction.
  • Background Scripts: JavaScript files running in the background, executing tasks even when tabs aren’t open.
  • Popup UI: The user-facing interface of your extension, often accessed via a small browser icon.
  • Content Scripts: Interact directly with web pages to gather data or modify them.

Directory Structure:

  • json
  • <content>.js [ Javascript Files]
  • <markup>.html [ HTML files ]
  • png

Here, we are going to make a simple “Hello World” extension for this tutorial. Efficient and Meaningful extensions which require basic understanding will follow up next

Step 1: Create a new Directory, this is where we will keep all our files.

Step 2: Create a file called Manifest.json

Here’s the Basic Format.

{
"manifest_version": 2,
"name": “EXTENSION NAME",
"description": "DESCRIPTION",
"version": "1.0",
"browser_action": {
"default_icon": “ICON (WITH EXTENSION) ”,
"default_popup": “LAYOUT HTML FILE"
},
"permissions": [
//ANY OTHER PERMISSIONS
]
}

Here is our Manifest.json file

{
"manifest_version": 2,
"name": "Hello World!",
"description": "This extension shows a Hello World message!",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "window.html"
}
}

So once’s you’ve got the hang of manifest.json, let’s go ahead.

Step 3: Create a new file called window.html.

It is the HTML that POPS UP when you click the Chrome extension button.

<!DOCTYPE html>
<html>
<head>
<script src="background.js"></script>
</head>
<body>
<div>Hello! Geeks For Geeks !!</div>
<div>This is a Chrome Extension!</div>
<div>And this is some html</div>
</body>
</html>

Step 4: Create the javascript file, let’s call it, background.js, Since we are creating a simple HTML file, you can skip this step completely as our present project won’t be needing any javascript.

We are creating it just for demonstrating how to include the script in the extension.

Step 5: You must have observed that an icon is an integral part of the extension, where you can click and begin the execution of the extension.

We are adding an icon file, from which you can get an idea.

icon.png (https://developer.chrome.com/extensions/examples/tutorials/getstarted/icon.png)

Screen Shot 2015-12-24 at 5.19.51 PM

This is how your directory must be looking after creating all 4 files.

The Last One:

To Load the extension,

  • Drag and drop the directory where your extension files live onto chrome://extensions in your browser to load it.
  • If the extension is valid, it’ll be loaded up and active right away!

Screen Shot 2015-12-24 at 5.19.00 PM

Open the chrome://extensions page.

Drag the folder to the chrome://extensions page.

Screen Shot 2015-12-24 at 5.20.47 PM

Installation Successful!

Click on the icon & the message will get displayed!

Screen Shot 2015-12-24 at 5.21.21 PM

 

For Windows: If you are using windows, you can follow the below steps.

  • Go to chrome://extensions in your Google Chrome browser. Check the Developer mode checkbox in the top right-hand corner. 

Chrome Extension

  • Click “Load Unpacked” to see a file-selection dialog. 

Load Unpacked

  • Select your extension directory, if the extension is valid, it’ll be loaded up and active right away! 

Select Your Extension Directory

This simple Hello World extension gives us the basic knowledge of How we can begin creating Chrome Extensions, as we are now familiar with manifest.json and directory structure, the two new things apart from basic web technologies like HTML, CSS, JavaScript, JQuery, etc.



Similar Reads

Building a Daily Motivational Quotes - Google Chrome & Microsoft Edge Extension
We will learn how to build a daily motivational quote for Google Chrome & Microsoft Edge Extension. As developers, programmers, or coders, we get demotivated at times, With this guide, you'll learn how to build your very own Daily Motivational Quote extension, empowering yourself and others with uplifting words of wisdom! Packed with clear inst
6 min read
Create a Crypto Currency Price Tracking Chrome Extension
Building a Chrome extension requires you to have a knowledge of HTML, CSS, JavaScript, and Bootstrap. In this article, we will be making an extension that tracks the prices of various cryptocurrencies. For fetching the data regarding the prices of cryptocurrencies, we will be using an API known as CryptoCompare. What is an API? API stands for appli
6 min read
Chrome Extension - Youtube Bookmarker
In this article, we'll develop a chrome extension using which the user can create bookmarks corresponding to different timestamps, store them somewhere(for now in chrome local storage), and retrieve the bookmarks(stored as timestamped youtube video links). The code is hosted here: GitHub. The video explainer for the main extension can be found here
15 min read
13 Best Chrome Extension To Boost the Productivity For Developers[2024]
Learning to code is one of the most challenging and probably the hardest things for newbie programmers. And once you have learned to code, and started working as a software developer, boosting your productivity is the other hardest for you in industries. There is no doubt that software developers always look for tools and technologies to develop th
9 min read
CSS Viewer Chrome Extension for Web Developers
CSS viewer inspect and displays the CSS properties of a web page. It is a very smart and useful extension that identifies CSS properties anywhere one points his mouse. It is time-saving and very fast, and also it makes identifying CSS easy. It allows one to click on any image, button, text, etc on a web page and we can instantly see the CSS code th
4 min read
How to Add Blocked Extension on Chrome?
Google Chrome extensions are small software programs that enhance the browsing experience. Thousands of extensions are available in the Chrome Web Store, where users can find easy solutions to streamline tasks, improve efficiency, and personalize their online experience. Besides this, extensions of Google Chrome have a vast library of collections.
3 min read
10 Best Chrome Extension for Youtube
YouTube is no doubt one of the most used and popular video platforms where many people over the world make and post their videos, and try to connect with other people. As the use of YouTube has increased, it has made many modifications and updates offering cool features to the users. But what if you can get more cool and effective, useful features
8 min read
5 Best Chrome Extension for Note-Taking
Today taking notes is becoming a universal trend which is rising day by day. People take notes for different purposes like Grocery, Shopping lists, Businesses, reminders, and so on. The most popular among these purposes is taking notes related to studies and education. Since the method of online schooling has risen recently due to the COVID-19 Pand
8 min read
10 Best Chrome Extension For Web Developers
When it comes to development, Google Chrome stands as the top choice for developers worldwide, offering unparalleled productivity boosts. In a decade, it's eclipsed competitors like Firefox, Edge, and Safari. Why this dominance? Chrome's powerful built-in developer tools and its massive marketplace of extensions streamline and enhance every aspect
7 min read
How to Build a Crypto Price Tracker- Google Chrome Extension ?
In this article, we will build a simple Google Chrome extension. After this, you can develop your own extensions very quickly. Prerequisite: So before we start we need some basic things on our computer.  Download or update your Google Chrome to the latest version. Now we need an IDE where we can write our code, here I am using VS Code.Creating Appl
4 min read
Create A Chrome Extension in HTML CSS & JavaScript
We are going to use HTML, CSS, and JavaScript to create a Chrome extension. Whether you're a beginner or an experienced developer, this article will walk you through the process, from conceptualization to coding and testing. By the end, you'll have the skills to craft personalized Chrome extensions, enhancing your browsing experience in the way you
6 min read
The 10 Best Chrome Extension for Colour Picker
Choosing the right color picker extension for Chrome can significantly streamline your design workflow, whether you're a web developer, graphic designer, or just someone who loves to customize digital projects. The 10 Best Chrome Extension for Colour Picker list brings together the top tools available right now, including popular choices like Color
12 min read
10 Must Have Chrome Extensions For Chrome
There are multiple Chrome extensions available for Chrome. Many of these offer a vast range of features such as blocking advertisements, saving passwords, etc. Articles are saved on "Pocket" for later reading while notes in "Google Keep" are synchronized between devices. "Session Buddy" recovers sessions and handles tabs. "HTTPS Everywhere" guarant
8 min read
Basic and advance shortcut keys in Google Chrome Browser
In the digital age, where time is a precious commodity, efficiency reigns supreme. For the savvy web user, mastering Chrome keyboard shortcuts is akin to unlocking a secret of productivity tools. Imagine gliding through tabs with the agility of a seasoned surfer, effortlessly opening windows with a flick of the wrist, and conducting precise searche
11 min read
How to trim a file extension from string using JavaScript ?
Given a fileName in string format and the task is to trim the file extension from the string using JavaScript. replace() method: This method searches a string for a defined value or a regular expression, and returns a new string with the replaced defined value. Syntax: string.replace(searchVal, newvalue) Parameters: searchVal: It is required parame
4 min read
How to enable PHP's openssl extension to install Composer ?
To perform the secure HTTPS transfers you will need to enable the openssl extension then you have to install the composer. In this article, we will cover the enabling openssl for XAMPP as well as WAMP one by one then we will install the composer. Enable openssl extension on XAMPP Enable openssl extension on WAMP Installation of Composer Enable PHP’
3 min read
How to install the ext-curl extension with PHP 7 ?
The ext-curl CURL stands for client user, In Linux cURL is a PHP extension, that allows us to receive and send information via the URL syntax. And ext-curl is the extension in the latest PHP-7 which is loaded with some of the advanced features of the basic curls. The following are the steps to add ext-curl extension in Ubuntu - 1. Update the Extens
1 min read
How to make a Slider tooltip extension using jQuery Mobile ?
jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a Slider tooltip extension using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=”stylesheet” href=”http://code.jquery.com/mobile/1.4.5/j
1 min read
How to extract extension from a filename using PHP ?
In this article, we will see how to extract the filename extension in PHP, along with understanding their implementation through the examples. There are a few different ways to extract the extension from a filename with PHP, which is given below: Using pathinfo() function: This function returns information about a file. If the second optional param
2 min read
How to get a File Extension in PHP ?
In this article, we will learn how to get the current file extensions in PHP. Input : c:/xampp/htdocs/project/home Output : "" Input : c:/xampp/htdocs/project/index.php Output : ".php" Input : c:/xampp/htdocs/project/style.min.css Output : ".css" Using $_SERVER[‘SCRIPT_NAME’]: $_SERVER is an array of stored information such as headers, paths, and s
2 min read
How to Install imap extension in PHP on Windows?
IMAP stands for Internet Message Access Protocol. It is an application layer protocol. PHP-IMAP is used to efficiently access messages from the IMAP server. IMAP stores email on the server and can download on-demand. To access the IMAP server we have to use PHP IMAP extension, now using this extension we can execute several operations to get differ
2 min read
How to Install PHP intl extension in Ubuntu?
The Internationalisation (Intl) extension is a wrapper for the ICU library, a collection of C/C++ and Java libraries that provide Unicode and Globalisation support for software applications. It tends to closely follow ICU APIs so that people having experience working with ICU in either C/C++ or Java could easily use the PHP API. Intl consists of se
2 min read
How to Install imap extension in PHP on Linux?
The Internet Message Access Protocol (IMAP) is an application layer protocol that allows a client to efficiently access emails from anywhere. It stores email on the server and can download on-demand. It is like an intermediary between client and email servers. It was designed by Mark Crispin in 1986 as a remote access mailbox protocol and the curre
3 min read
How to Install mcrypt extension on Ubuntu?
PHP mcrypt is an extension. It provides encryption facilities for web applications that require the functionality of modern algorithms such as AES. It works as interface to Mcrypt’s libmcrypt library which implements all the algorithms and modes available in it like GOST, RC2, RC6, MARS, etc. Here, .php extension means a plain text file that contai
3 min read
How to Install mcrypt extension in xampp?
MCrypt replaces the old crypt() package and the crypt(1) command, with add-ons. MCrypt is a file encryption method. It uses secure techniques to exchange data. It enables users to encrypt files or data streams without the need for cryptography. It allows developers to use a wide range of encryption features, with no drastic changes to their code. I
2 min read
How to Install PHP Extension in Ubuntu?
PHP extensions are compiled libraries that allow you to use special functions in your PHP code. PHP extensions can be compiled statically in PHP or dynamically loaded at the time of execution. By using extensions, you can prevent the need to recreate the same code for many applications. To use an extension, all you need to do is connect it to the P
2 min read
How to Install PHP Extension in cPanel?
PHP (Hypertext Preprocessor) is known as a broadly useful prearranging language that can be utilized to foster dynamic and intelligent sites. It was among the main server-side dialects that could be inserted into HTML, making it more straightforward to add usefulness to pages without expecting to call outer records for information. A PHP expansion
1 min read
How to Install PHP Soap Extension?
PHP is a general-purpose scripting language that is mainly used for Web development to built dynamic and interactive web pages. Because of its free availability and efficiency, it is widely used among web developers. It has many extensions to get and use web services to make the website more interactive. One of the famous php extension is the SOAP
3 min read
React Suite Icon extension React Icons
A React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we'll learn about React Suite Icon extension React icons. React Icons, contains various popular
3 min read
React Suite Icon extension Font awesome icons
A React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we'll learn about React Suite Font Awesome Icons. In react suite, we can also use all types of f
3 min read