Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Odd Encoding of Scripts served via CDN
Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Apr 27, 2019 - 4:43 pm

I'm not certain character encoding is the correct term, but something is happening to sp scripts when we attempt to serve them up via CDN.

We are desperately trying to get the Hummingbird site optimization plugin working with Simplepress. It handles caching, gzip, and asset optimization among other things. I've got it working well for all our CSS files, and most scripts on our site, but we encounter an issue with SimplePress scripts when activating its CDN function.

I have a lengthy support topic going on with the Hummingbird devs, but while I await further answers I wanted to share this here to see if the @spsupport experts have any insight.

Please compare the two screenshots, viewing the source of sp-forum.min.js. This is just one example, of what I think is causing all forum functions to fail with the CDN active.

One shows the clean script code hosted on our server, viewed via cPanel. The second shows the same file hosted on the CDN. Notice the odd characters.

I have combining and caching turned off in Simplepress for js and css, as this has been working well to let Hummingbird do that. No problems with CSS files!

I have also cleared all SP cache (css, script, xml, and general). This issue only presents itself when turning on the CDN, without any further combining or minification of individual files.

I say "character encoding" because we also get this warning in the browser:

The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.

Even though, we do have the charset="UTF-8" meta tag in our site header. I read this warning can come from specific files (e.g.; scripts) and not necessarily the HTML.

Thanks in advance for any possible feedback.

 

spscript-local.pngImage Enlarger

File on Host Server

spscript-cdn-2.pngImage Enlarger

File on CDN

script-errors.pngImage Enlarger

Script Failure Warnings

charset.pngImage Enlarger

Character Encoding Warning

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Simple Press
Admin
sp_UserOfflineSmall Offline
Apr 27, 2019 - 11:46 pm

That's interesting - looks like the CDN is trying to do some optimization of its own and is corrupting the file.  Not sure what CDN you're using but we use cloudflare and don't encounter any issues like this.

Also, do not let any caching plugin (including hummingbird) combine the css and js scripts.

Another thing you you might try is to turn on the SP_SCRIPT_DEBUG flag in wp-config and set it to true - that should serve up mostly the non minified version of the scripts - see if that helps.

Thanks.

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Apr 28, 2019 - 2:51 pm

Thanks for the feedback!

This is rather puzzling, and I continue troubleshooting since of the 65+ scripts loading with our theme and various plugins, the only scripts files that are causing any issues when served up via the CDN are all related to SimpePress...

List of scripts HB Breaks:
/**handles: spforum **/
/**handles: spforumevents **/
/**handles: sfprintthis **/
/**handles: spabjs **/
/**handles: sp-pm **/
/**handles: sp-subscriptions **/
/**handles: jquery.msdropdown **/
/**handles: spforumfooter **/

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Simple Press
Admin
sp_UserOfflineSmall Offline
Apr 28, 2019 - 2:59 pm

Yeah, that is weird. I can't even hazard a guess as to what could be happening.  They're just standard text files...

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Apr 28, 2019 - 3:02 pm

Simple Press said
you might try is to turn on the SP_SCRIPT_DEBUG flag in wp-config and set it to true...

Which is it?

SP_SCRIPT_DEBUG

OR

SP_SCRIPTS_DEBUG

The latter is defined in the SP docs.

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Simple Press
Admin
sp_UserOfflineSmall Offline
Apr 28, 2019 - 3:04 pm

Sorry, you're right - its SP_SCRIPTS_DEBUG not SP_SCRIPT_DEBUG.

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
May 1, 2019 - 11:05 am

Simple Press said
...do not let any caching plugin (including hummingbird) combine the css and js scripts. 

For the record – and for anyone else ever using Hummingbird – this was the only way we could get SP scripts working when minified and served up via the WPMU Dev CDN: by turning off CSS/JS Combined Caching via the SP Admin, and defining SP_SCRIPTS_DEBUG in wp-config.

So...thanks for that little hack! Are there any negative impacts of using that wp-config edit? In terms of performance or security?

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Simple Press
Admin
sp_UserOfflineSmall Offline
May 1, 2019 - 1:24 pm

Since the scripts are not minified, it will take slightly longer to download and slightly longer for the browser to parse them.  It is possible that the CDN will compress them before sending them to the browser but I have no way of knowing that for sure.  Still, I doubt that most users running on modern hardware would experience an impact that is measurable.

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
May 1, 2019 - 2:03 pm

Simple Press said
It is possible that the CDN will compress them before sending them to the browser...

FYI: Yes, Humming bird minifies the assets and serves up cached css and scripts from the CDN.

So far, so good.

Thanks again!

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17357
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10123
Posts: 79616