cham_eleon
cham_eleon

Reputation: 31

WordPress Assets not loaded correctly because of attached '='defer

My WordPress Installation appends '='defer to all JS URLs.

Now they are not found anymore becuase they obviously do not exist.

<script src="https://example.org/wp-includes/js/jquery/jquery-migrate.min.js&#039;=&#039;defer" id="jquery-migrate-js"></script>
<script src="https://example.org/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js&#039;=&#039;defer" id="jquery-blockui-js" data-wp-strategy="defer"></script>

What can I do to fix that? It's happening for all kind of JS files.

I tried a lot of functions.php snippets already, but nothing helped.

Upvotes: 1

Views: 76

Answers (1)

cham_eleon
cham_eleon

Reputation: 31

Okay, that was for sure my mistake. In my functions.php I had the following code:

if (is_user_logged_in()) {
} else {
    function defer_parsing_of_js($url)
    {
        if (false === strpos($url, ".js")) {
            return $url;
        }
        if (strpos($url, "jquery.min.js")) {
            return $url;
        }
        return "$url' defer='defer";
    }
    add_filter("clean_url", "defer_parsing_of_js", 11, 1);
}

the filter is not required anymore... removed it => works fine now

Upvotes: 0

Related Questions