Skip to main content
All CollectionsTroubleshootingFeatures and Optimizations
How to Fix the “jquery is not defined” Error
How to Fix the “jquery is not defined” Error
Updated over a year ago

You have just loaded your website, and something is now working right. Upon checking the Console, you see the following error:

jQuery is not defined

image5.png

The error means that a script that requires jQuery to function properly has been executed, but due to the optimization or other exclusions that you have, the jQuery library was not yet loaded when that initial script runs and therefore triggers an error.


Check if NitroPack is the culprit for the “jquery is not defined” error

Load your page while bypassing the NitroPack cache; this can be done by adding /?nonitro to the URL (e.g., example.org/?nonitro).

image2.png

You should then check if the error is present on the non-optimized version of your page as well.

⚠️If the error is present, this means that NitroPack is not the cause, and you should check your website code or consult with a Developer.


The error is not present on the unoptimized page

If the error is present only when NitroPack is active on the page, you shouldn’t worry.

✅Here’s an easy way to fix the “jquery is not defined” error by yourself.

What you need to do is exclude the jQuery library from optimization.

To do so, head over to NitroPack’s DashboardSettingsGeneralExcluded Resources.

Add the following exclusion:

  • Asset URL/Code:
    *jquery*

  • Resource Type:
    JavaScript

And leave the rest as it is.

image1.png

ℹ️The asterisks are needed for NitroPack to catch all of the files containing that common string.

💡We then recommend doing a full cache purge so that NitroPack can create the new optimizations where the issue should no longer be present.

You can do this via the NitroPack’s Dashboard > Cache status tab.

📌 If you need any assistance or have questions, you can always reach out to our support team at [email protected] or via this link: https://support.nitropack.io

Did this answer your question?