Monday, March 14, 2022

[SOLVED] Loading javascripts from src to inline problem

Issue

I generate from server html markup for small JS files like this:

<script defer src="external-script.js"></script>

But in Chrome I see:

<script type="text/javascript" charset="UTF-8" defer>
//<![CDATA[
.... content of my JS file
//]]>
</script>

Why? Who and how did it? It breaks my order loading scripts. Problem is that defer working with src attribute only. When source code is inside , then defer is not accepted and I have some undefined functions called.


Solution

After some experiments I found that on hosting server is installed Pagespeed module which dooing this change.

I fixed put this into my htaccess:

<IfModule pagespeed_module>
  ModPagespeedDisableFilters inline_javascript
</IfModule>


Answered By - step
Answer Checked By - Timothy Miller (WPSolving Admin)