Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: drewactual on April 24, 2019, 08:39:03 AM

Title: combining and minifying JS
Post by: drewactual on April 24, 2019, 08:39:03 AM
css is easy... JS is a PITA.   I guess it's all about getting them in the right order and eliminating conflicts.  I'm knee deep in this and have been caught on a significant snag I seek help for:

question 1: jQuery~ On my page there are calls to jQuery from 1.7 to 3.3.1, and all by mod's.  the base page will operate in any browser i've tested w/o any calls to jQuery at all- a testament to modern browsers?- but several mod's need them, apparently.  However, I've discovered through trial and error that 3.3.1 will operate ALL the mod's as expected and there is no need for additional calls.... so.... is this wise?  My objective is to call in either a combined and minified JS with the jQuery atop all others, or, jQuery only the one time (directly from the content delivery service; e.g. google) and then a combined JS.   what is the best way to go about this in your experience (which has just about got to be more than mine)?


question 2: conflicts if ^ isn't possible- how do you guys approach these multiple jQuery and java files that often butt heads? do you use noConflict or change the var names throughout the files?  What is the best strategy?

many thanks in advance.
Title: Re: combining and minifying JS
Post by: Kindred on April 24, 2019, 09:22:49 AM
mods should all use noconflict at the very least
Title: Re: combining and minifying JS
Post by: drewactual on April 25, 2019, 12:58:06 PM
turns out i didn't have a conflict at all... i had compression set to off in SMF and was doing it server side... using zlib_compression as opposed to output in the ini file, and it corrupted all the xmlhttprequests... so... turns out i can still use brotli, and gzip, and by simply setting the output handler to zlib and turning it over to SMF to compress..

the only gzip files are the index @ dns lookup, and the xmlhttprequests... everything else is brotli(br), and..... the page has all it's function and all it's speed back.

i've been looking for a JS conflict for literally two weeks that didn't exist.  it was all about corrupted compression.
Title: Re: combining and minifying JS
Post by: drewactual on April 25, 2019, 01:00:50 PM
thank you for your response, kindred...

I now have a true conflict, but it should be a lot easier to find.... mentions doesn't offer the little drop down... not a big deal.