Adding jQuery 3 / How to prevent JavaScript automatic minifying

SOLVE
Highlighted
New Contributor

Hi there.

I recently encountered a problem with automatic JS formatting from HubSpot' s side.

 

Im am disabling loading jQuery old version which is automaticly included and adding JQuery 3.3.1. Im doing this trough a hubl template, replacing

      	{{ standard_header_includes|replace('/hs/hsstatic/jquery-libs/static-1.4/jquery/jquery-1.11.2.js', get_public_template_url('appxite_2018/js/vendor/jquery_3_3_1_min.js')) }}

While the browser clearly shows that the new jQuery is loaded and the old one is not, first I noticed that it changes the file from jquery_3_3_1_min.js to jquery_3_3_1_min.min.js . Furthermore, it changes the code inside. For example:

 

!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");

is changed to

!function(b,a){"object"==typeof module&&"object"==typeof module.exports?module.exports=b.document?a(b,!0):function(c){if(!c.document){throw new Error("jQuery requires a window with a document")

And it causes JS to not function due to error - ReferenceError: a is not defined

Is there a way to stop Hubspot from minifying this or some other way to replace the older jQuery libraries to newest ?

 

 

1 Accepted solution

Accepted Solutions
Regular Advisor | Gold Partner | HubSpot Certified Trainer

@MartinsC - Just use the unminified version of jQuery Smiley Very Happy

https://code.jquery.com/jquery-3.3.1.js

 


If this answer helped, please, mark as solved Smiley Very Happy


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

1 Reply
Regular Advisor | Gold Partner | HubSpot Certified Trainer

@MartinsC - Just use the unminified version of jQuery Smiley Very Happy

https://code.jquery.com/jquery-3.3.1.js

 


If this answer helped, please, mark as solved Smiley Very Happy


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.