How to add jQuery to an external JavaScript file for building a Chrome Extension?

262 views Asked by At

I am learning JavaScript and I am planning to make a Chrome extension. I am making an Age Calculator. I have developed some code. I am stuck at how to use jQuery in an external JavaScript File?

if (ageYears > 0) {
    document.write(ageYears +" year");
    if (ageYears > 1) document.write("s");
        if ((ageMonths > 0)||(ageDays > 0)) document.write(", ");
    }
    if (ageMonths > 0) {
        document.write(ageMonths +" month");
        if (ageMonths > 1) document.write("s");
        if (ageDays > 0) document.write(", ");
}
if (ageDays > 0) {
    document.write(ageDays +" day");
    if (ageDays > 1) document.write("s");
}

manifest.json

{
    "name": "Age Calculator",
    "description": "This application gives you a calculation of how old are you today, since the day you were born.",
    "version": "0.1",
    "manifest_version": 2,

    "app": {
        "background": {
            "scripts": ["background.js"]
          }
    },
    "icons": { "128": "calendar-128.png" }
    "author" : "Miral Kumbhani"
}
1

There are 1 answers

3
Demoncious On

Just get all of that code into an external JavaScript file and in your main file under where jQuery.js is linked link the file i.e

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="FILENAME.js"></script>